All threads / Are you adding # frozen_string_literal: true to your config files

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Are you adding # frozen_string_literal: true to your config files

Stéphane Paquet asked in Rails

I was wondering if some of you are adding # frozen_string_literal: true to their config files?

This never became the default in Ruby 3 unfortunately. See: https://bugs.ruby-lang.org/issues/11473#note-53

I don't use it, but I probably should although I'm sure I modify strings like this more often than I realize. It's a pretty great performance improvement when you can use it!

Some more good reading: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/

I cannot agree more regarding the performance improvement. I also think it's a good practice to avoid changing a string that we wanted to be static ;-)

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 51,723+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.