Pattern Matching • Exercise 1/4

Array Destructuring

00:00
0
25 points

Instructions

Create a function first_two that uses pattern matching to extract
the first two elements from an array.

Use the in pattern matching syntax:
ruby
case array
in [first, second, *rest]
# use first and second
end

Return an array with just the first two elements.

Your Code

Results

Click "Run Tests" to see results