Named tuples are similar to tuples in Julia, except in named tuples we can provide a name for each component in the named tuple.
In named tuples, we can access each component additionally with its name using dot syntax (tuple.name
).
(name=value, name=value)
Let's take a look at an example of this.
#declare and initialize tuplet = (a=5, b=10)#access element using indexprintln(t[1])#access element using nameprintln(t.a)
In the above code snippet:
t
.index
to access the element.t
.