December 25 - Create an Immutable Array in Ruby
In this coding exercise you'll learn how to create an immutable array in Ruby.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

Summary

Create an immutable array in Ruby.

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.

Test Cases

Code File