Ruby - Class Methods and Variables
What will be the output of this Ruby code?
arr = [1, 2, 3] arr.freeze arr << 4 puts arr.inspect
arr = [1, 2, 3] arr.freeze arr << 4 puts arr.inspect
arr is frozen with arr.freeze, so it cannot be changed.arr << 4, which modifies the array. Since it's frozen, this raises a runtime error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions