Skip to content

Instantly share code, notes, and snippets.

@hanachin
Last active December 20, 2018 07:20
Show Gist options
  • Save hanachin/c946c73264c4952cd8cab7d4e694f564 to your computer and use it in GitHub Desktop.
Save hanachin/c946c73264c4952cd8cab7d4e694f564 to your computer and use it in GitHub Desktop.
Ruby 2.6のASCII以外の大文字で定義できる定数を試す ref: https://qiita.com/hanachin_/items/1db0ddfeeff43b8420dd
% ruby='𝐀=42; p defined?(𝐀)'; RBENV_VERSION=2.5.3 ruby -ve $ruby; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
"local-variable"
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
"constant"
% ruby='binding.local_variable_set(:𝐀, 42)'; RBENV_VERSION=2.5.3 ruby -ve $ruby; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `local_variable_set': wrong local variable name `𝐀' for #<Binding:0x0000556103d9c880> (NameError)
% ruby='/(?<𝐀>a)/ =~ "a"; p binding.local_variables; p 𝐀'; RBENV_VERSION=2.5.3 ruby -ve $ruby; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
[:𝐀]
"a"
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
[]
"a"
% ruby='class 𝐀; end; /(?<𝐀>a)/ =~ "a"; p 𝐀'; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
-e:1: warning: already initialized constant 𝐀
-e:1: warning: previous definition of 𝐀 was here
"a"
% ruby='class C; end; /(?<C>a)/ =~ "a"; p C'; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment