Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tuples

Exercise 1: Creating and Accessing Tuples

Task: Create a tuple representing a book. The tuple should contain three elements: the title of the book as a String, the year of publication as an Int, and a Boolean indicating whether you have read it. Then, write code to print each element of the tuple separately.

Exercise 2: Tuple Destructuring

Task: Given a tuple representing a person (firstName, lastName, age), destructure it into separate variables and print a formatted string using these variables.

Exercise 3: Using Tuples in Functions

Task: Write a function that takes two numbers as parameters, returns a tuple containing the sum and product of the two numbers.