# frozen_string_literal: true str = 'foo' str << 'bar'
# main.rb:3:in `<main>': can't modify frozen String (RuntimeError)
str = 'foo'.freeze str << 'bar' # main.rb:2:in `<main>': can't modify frozen String (RuntimeError)
You can also trigger this behavior globally with the --enable=frozen-string-literal option.
[1]: https://github.com/ruby/ruby/blob/v2_3_0/NEWS#L17-L26
[2]: http://ruby-doc.org/core-2.2.3/Object.html#method-i-freeze
You can also trigger this behavior globally with the --enable=frozen-string-literal option.
[1]: https://github.com/ruby/ruby/blob/v2_3_0/NEWS#L17-L26
[2]: http://ruby-doc.org/core-2.2.3/Object.html#method-i-freeze