ComeçarComece de graça

Create, index, and slice a tuple

You've seen that one of the major differences between a tuple and other data structures, such as a vector is the immutability of the tuple. The creation of a tuple is very similar to that of a vector, and indexing and slicing will also be familiar to you, using the square bracket notation.

In this exercise, you will create, index, and slice a tuple that you will call emergency_information. This tuple should contain the three fields that you identified in the previous question as good data to store in a tuple.

To create a tuple, remember that you need to use parentheses () to contain the values you wish to store in the tuple.

To index and slice a tuple, use the square bracket [] notation after the name of the tuple. Indexing starts at 1 for the first element in Julia.

Este exercício faz parte do curso

Intermediate Julia

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Create a tuple containing the emergency information
emergency_information = (____, ____, ____)
Editar e executar o código