Tutorial by Examples

Tuples are immutable ordered collections of arbitrary distinct objects, either of the same type or of different types. Typically, tuples are constructed using the (x, y) syntax. julia> tup = (1, 1.0, "Hello, World!") (1,1.0,"Hello, World!") The individual objects of a tup...
The typeof a tuple is a subtype of Tuple: julia> typeof((1, 2, 3)) Tuple{Int64,Int64,Int64} julia> typeof((1.0, :x, (1, 2))) Tuple{Float64,Symbol,Tuple{Int64,Int64}} Unlike other data types, Tuple types are covariant. Other data types in Julia are generally invariant. Thus, julia>...
Because Julia function parameter lists are themselves tuples, dispatching on various kinds of tuples is often easier done through the method parameters themselves, often with liberal usage for the "splatting" ... operator. For instance, consider the implementation of reverse for tuples, fr...
Tuples are frequently used for multiple return values. Much of the standard library, including two of the functions of the iterable interface (next and done), returns tuples containing two related but distinct values. The parentheses around tuples can be omitted in certain situations, making multip...

Page 1 of 1