Ruby local_variable 可用命名格式
a
_a
name
first_name
hello48
user_ID
_
Ruby如何区分local_variable /keyword/ method call
Identifier | difference |
---|---|
keyword | 诸如def 、if 之类keyword,Ruby内置一张关键词的表,可以直接判断出来 |
local_variable | 赋值符号 = 左边的就是local_variable |
method call | 其余的就是method call |
复习 : ruby -e 可以直接执行脚本
Ruby可以知道abc
肯定不是keyword
,但是还无法确定abc
是local_varaible
还是 method call
PS C:\Users\Administrator> ruby -e "abc"
-e:1:in `<main>': undefined local variable or method `abc' for main:Object (NameError)
reference
《The Well-Grounded Rubyist, Second Edition》
(https://www.manning.com/books/the-well-grounded-rubyist-second-edition)
2.5.4. Local variables and the things that look like them
のほほ~ん
∫∫ ∫∫
∧_∧
(´∀`)つ
|∪ ̄ ̄ ̄|
| ┼─┼ |
| /\ |
|/ 茶 \|
\___/
└─┘
http://emoji.vis.ne.jp/nohohon5.htm