symbols is placeholders for identifiers and strings.

By admin in on 2019年6月15日
# You can recognize symbols because they are always prefixed by a colon (:).
# You don't directly create a symbol by assigning a value to it. 
# You create a symbol by calling the to_sym or intern methods on a string or by assigning a symbol to a symbol. 

name = 'myValue'
name.to_sym # => :myValue
:myValue.id2name # => 'myValue'
name == :myValue.id2name # => true


电子邮件地址不会被公开。 必填项已用*标注

Copyright @ 2010-2019 美高梅手机版4858 版权所有