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?

Reply

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/

Reply

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 ;-)

Reply
Join the discussion
Create an account Log in

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

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

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