Tuples
Tuples give you a way to group related data of different types into small collection-like data structures. In MPS, tuples are available within the jetbrains.mps.baseLanguage.tuples language.
Indexed tuples
Indexed tuple is a structure, which can contain several elements of arbitrary types and elements of which can be accessed by an index. The MPS implementation represents a tuple instance by a Java object. The usual meaning of '=' and '==' operations on Java objects within MPS remains unchanged.
Named tuples
Named tuples are similar to indexed tuples, with the difference that elements are accessed by name instead of by index. To use named tuples in the model you first need to explicitly define them in your model (new ->jetbrains.mps.baseLanguage.tuples/tuple).
Declaration of Pair:
Named tuple declaration
A root node of concept NamedTupleDeclaration contains a single declaration.
declaration part | allowed contents |
---|---|
tupleName | any valid identifier |
elementType | either a primitive type or any type that reduces to Java classifier |
elementName | any valid identifier |