In this coding exercise, you’ll learn how to create an immutable array in Ruby.
Summary
Create an immutable array in Ruby.
Exercise File
Exercise Description
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
Example Process
[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.
Solution
Can be found on the solutions branch on github.
Hi Jordan.
You forgot to add this example in “Ruby Coding Exercises” playlist on YouTube.
Thanks for example.