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 tuple t = (a=5, b=10) #access element using index println(t[1]) #access element using name println(t.a)
In the above code snippet:
t
.index
to access the element.t
.RELATED TAGS
CONTRIBUTOR
View all Courses