Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Eiffel (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Tuples=== Tuples types may be viewed as a simple form of class, providing only attributes and the corresponding "setter" procedure. A typical tuple type reads <syntaxhighlight lang="eiffel"> TUPLE [name: STRING; weight: REAL; date: DATE] </syntaxhighlight> and could be used to describe a simple notion of birth record if a class is not needed. An instance of such a tuple is simply a sequence of values with the given types, given in brackets, such as <syntaxhighlight lang="eiffel"> ["Brigitte", 3.5, Last_night] </syntaxhighlight> Components of such a tuple can be accessed as if the tuple tags were attributes of a class, for example if <code>t</code> has been assigned the above tuple then <code>t.weight</code> has value 3.5. Thanks to the notion of assigner command (see below), dot notation can also be used to assign components of such a tuple, as in <syntaxhighlight lang="eiffel"> t.weight := t.weight + 0.5 </syntaxhighlight> The tuple tags are optional, so that it is also possible to write a tuple type as <code>TUPLE [STRING, REAL, DATE]</code>. (In some compilers this is the only form of tuple, as tags were introduced with the ECMA standard.) The precise specification of e.g. <code>TUPLE [A, B, C]</code> is that it describes sequences of ''at least'' three elements, the first three being of types <code>A</code>, <code>B</code>, <code>C</code> respectively. As a result, <code>TUPLE [A, B, C]</code> conforms to (may be assigned to) <code>TUPLE [A, B]</code>, to <code>TUPLE [A]</code> and to <code>TUPLE</code> (without parameters), the topmost tuple type to which all tuple types conform.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)