我正在寻找 Ruby 中所有魔法指令的列表。
例如:
#!/usr/bin/ruby -w
# encoding: windows-1252
# warn_indent: false
# frozen_string_literal: true
Run Code Online (Sandbox Code Playgroud)
您在那里提到的链接有一个指向Ruby 源代码的链接,其中定义了这些:
static const struct magic_comment magic_comments[] = {
{"coding", magic_comment_encoding, parser_encode_length},
{"encoding", magic_comment_encoding, parser_encode_length},
{"frozen_string_literal", parser_set_compile_option_flag},
{"warn_indent", parser_set_token_info},
# if WARN_PAST_SCOPE
{"warn_past_scope", parser_set_past_scope},
# endif
};
Run Code Online (Sandbox Code Playgroud)
其中一个基于 a 门控#define,因此它可能是一个不完整或尚未发布的功能,可能在 Ruby 2.7 或 3.0 中被保留。
| 归档时间: |
|
| 查看次数: |
62 次 |
| 最近记录: |