Complete the code to get the first three elements of the array.
arr = [10, 20, 30, 40, 50] slice = arr[[1]]
The range 0..2 selects elements at indexes 0, 1, and 2, which are the first three elements.
Complete the code to get the last two elements of the array.
arr = [5, 10, 15, 20, 25] slice = arr[[1]]
The range -2..-1 selects the last two elements of the array using negative indexes.
Fix the error in the code to slice the array from index 1 to 3 inclusive.
arr = [2, 4, 6, 8, 10] slice = arr[[1]]
The range 1..3 includes indexes 1, 2, and 3. The range 1...3 excludes index 3.
Fill both blanks to create a slice from the second to the fourth element (inclusive).
arr = ['a', 'b', 'c', 'd', 'e'] slice = arr[[1]..[2]]
Indexes 1 to 3 correspond to the second, third, and fourth elements.
Fill all three blanks to create a slice from the third element to the last element.
arr = [100, 200, 300, 400, 500] slice = arr[[1]..[2]] puts slice[[3]]
The slice from index 2 to 4 includes elements 300, 400, 500. The first element of the slice is at index 0.