Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify docs about magic comments placement #4985

Merged
merged 1 commit into from
Oct 30, 2021

Conversation

splattael
Copy link
Contributor

Magic comments like frozen_string_literal may appear everywhere
within the first comment section while encoding have to be the first
line, or second line after shebang.

Examples

frozen_string_literal must appear in the first comment section

# any comment
# It's OK as long it's not a "token"

# frozen_string_literal: true

p ''.frozen? # => true

encoding must be first or second line

# another comment or empty line
# encoding: big5

p ''.encoding # => #<Encoding:UTF-8> so not #<Encoding:Big5>

Magic comments like `frozen_string_literal` may appear everywhere
within the first comment section while `encoding` have to be the first
line, or second line after shebang.
@hsbt hsbt merged commit 09bdb43 into ruby:master Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants