Freeze an array : freeze « Array « Ruby






Freeze an array


sequences = [[1,2,3], [1,2,4], [1,4,9]].freeze
sequences << [2,3,5]
# TypeError: can't modify frozen array
sequences[2] << 16                               # => [1, 4, 9, 16]

 

Related examples in the same category