Ruby - Arrays
What will be the output of this Ruby code?
arr = [1, 2, 3] arr.pop arr.unshift(0) p arr
arr = [1, 2, 3] arr.pop arr.unshift(0) p arr
arr.pop removes 3, so array becomes [1, 2].arr.unshift(0) adds 0 at front, so array becomes [0, 1, 2].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions