Ruby: "runtimeerror: can't modify frozen array" issue


array = [1, 2, 3].freeze
array << 4
This error is raised when you attempt to modify an object that has been frozen.


# Use dup to create a mutable copy or avoid freezing objects you might need to modify.
array = array.dup
array << 4

Beginner's Guide to Ruby