published: 2nd of August 2021
A Tuple in Crystal is a group of related values of possibly different types.
# Define a Tuple.
stuff_and_things = {"stuff", :things, 42}
# Access a Tuple element.
stuff_and_things[0] # => stuff
# Deduce the type of stuff_and_things
typeof(stuff_and_things) # => Tuple(String, Symbol, Int32)
NamedTuples allow you to create a key/value pair version of a Tuple.
# Define a NamedTuple.
stuff_and_things = {stuff: "stuff", things: :things, the_answer: 42}
# Access a NamedTuple element.
stuff_and_things[:the_answer] # => 42
# Deduce the type of stuff_and_things
typeof(stuff_and_things) # => NamedTuple(stuff: String, things: Symbol, the_answer: Int32)
https://pragprog.com/titles/crystal/programming-crystal/
https://crystal-lang.org/reference/syntax_and_semantics/literals/tuple.html
https://crystal-lang.org/reference/syntax_and_semantics/literals/named_tuple.html