ruby extract elements from array
arr = [1, 2, 3, 4, 5]
element = arr.pop
Explanation:
- In the first line, we create an array called arr
with the elements 1, 2, 3, 4, and 5.
- In the second line, we use the pop
method to remove and return the last element from the arr
array, which is 5.