Complete the code to freeze the string so it cannot be changed.
name = "Ruby".[1] name << "Lang"
Using freeze makes the string immutable, so appending to it causes an error.
Complete the code to freeze the array so it cannot be modified.
numbers = [1, 2, 3].[1] numbers << 4
Calling freeze on the array prevents adding new elements.
Fix the error by freezing the hash so it cannot be changed.
config = {mode: 'dark', volume: 10}
config.[1]
config[:mode] = 'light'Freezing the hash prevents changing its keys or values.
Fill both blanks to create a frozen array and check if it is frozen.
arr = [10, 20, 30].[1] puts arr.[2]
empty? or length instead of frozen?.First, freeze the array to make it immutable, then check with frozen?.
Fill all three blanks to freeze a nested hash and check if the nested array is frozen.
settings = {theme: 'blue', options: [1, 2, 3]}
settings = settings.[1]
puts settings[:options].[2]
settings[:options].[3]Freeze the outer hash, check if the nested array is frozen (it is not), then freeze the nested array separately to make it immutable.
