Ruby - Arrays
Identify the problem in this Ruby code:
arr = [1, 2, 3] arr.shift(2) p arr
arr = [1, 2, 3] arr.shift(2) p arr
shift(n) removes the first n elements and returns them.arr.shift(2) removes first two elements, so array becomes [3].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions