Ruby - Arrays
What is the output of this Ruby code?
arr = [5, 6, 7] arr.shift arr.push(8) p arr
arr = [5, 6, 7] arr.shift arr.push(8) p arr
arr.shift removes 5, so array becomes [6, 7].arr.push(8) adds 8, so array becomes [6, 7, 8].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions