there a simple example to show how the literal can be handled in ruby
if we run the first file literal.rb
the literal variable before call the .freeze
method is not frozen
» ruby literal.rb
Before freeze: false
After freeze: true
We can set all the literal to be frozen passing the --enable=frozen-string-literal
when we call the script
» ruby --enable=frozen-string-literal frozen.rb
Before freeze: true
After freeze: true
alternatevly we can add at the beginning of the file the # frozen_string_literal: true
comment that set all the literal present in the file to be frozen
» ruby literal_frozen.rb
Before freeze: true
After freeze: true