1

There are two ways of enabling all strings in a file to be implicitly frozen1.

# frozen-string-literal: true
# frozen_string_literal: true

Is there a difference between these two syntaxes?

Thanks!

Juanito Fatas
  • 8,551
  • 7
  • 44
  • 62
  • `# frozen-string-literal: true` is just a normal Ruby comment. Read this for `# frozen_string_literal: true` - https://stackoverflow.com/a/37799399/645886 – Surya Aug 26 '19 at 06:04

1 Answers1

2

The answer you link to never uses the magic comment # frozen-string-literal: true only # frozen_string_literal: true. The difference is that only the latter will work.

The other way to enable frozen string literals is to run the application with the --enable=frozen-string-literal flag.

philnash
  • 64,214
  • 10
  • 52
  • 79