In this coding exercise, you’ll learn how to create an immutable array in Ruby.
Create an immutable array in Ruby.
Given the following array:
[1, 2, 3]
Update the array so that it cannot be changed. If an attempt is made to alter the array, it should raise a runtime error
[1, 2, 3] << 4 # ~> RuntimeError: can't modify frozen Array
Real World Usage
Converting an array to be immutable is a process utilized on a daily basis in data science. Since it’s vital to be confident that collection data will be consistent, this feature is very important for building big data algorithms.
Can be found on the solutions branch on github.