Last active
December 20, 2018 07:20
-
-
Save hanachin/c946c73264c4952cd8cab7d4e694f564 to your computer and use it in GitHub Desktop.
Ruby 2.6のASCII以外の大文字で定義できる定数を試す ref: https://qiita.com/hanachin_/items/1db0ddfeeff43b8420dd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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