# tuple

tuple(xs...)

Construct a tuple of the given objects.

## Examples

``````julia> a = (1,2,3)
(1,2,3)``````
``````julia> a[3]
3``````
``````julia> a = (1,2,3)
a[3]
a[1] = 2
`setindex!` has no method matching setindex!(::(Int64,Int64,Int64), ::Int64, ::Int64)
1. Create a tuple with multiple elements:

``````julia> tuple(1, 2, 3, 4)
(1, 2, 3, 4)``````

This example creates a tuple with four elements: 1, 2, 3, and 4.

2. Create a tuple with a single element:

``````julia> tuple("Hello")
("Hello",)``````

Even when creating a tuple with a single element, Julia requires a trailing comma to distinguish it from a regular value.

3. Create an empty tuple:

``````julia> tuple()
()``````

This example demonstrates creating an empty tuple with no elements.

4. Create a tuple from an array:
``````julia> arr = [10, 20, 30]
julia> tuple(arr...)
(10, 20, 30)``````

By using the splat operator `...`, an array can be converted into a tuple.

Common mistake example:

``````julia> tuple([1, 2, 3])
([1, 2, 3],)``````

In this example, the `tuple` function is called with an array as an argument. However, instead of converting the array elements into a tuple, it creates a tuple with the array itself as a single element. To convert an array into a tuple, use the splat operator `...` to expand the array elements within the `tuple` function call.