开发者

What is the difference between :method and :"method$##11" symbol?

开发者 https://www.devze.com 2023-03-17 23:14 出处:网络
Is :\"method$##11\" format used when special characters comes in开发者_运维知识库side the symbol?Yes, if your symbol name contains anything other than letters/numbers/underscores, you can quote it ins

Is :"method$##11" format used when special characters comes in开发者_运维知识库side the symbol?


Yes, if your symbol name contains anything other than letters/numbers/underscores, you can quote it instead and it'll still be a symbol (otherwise you will get syntax errors when you don't use the quotes).

Also, using the same name quoted vs unquoted will be treated as the same symbol:

:test == :test2
# => false
:test == "test"
# => false
:test == :"test"
# => true
:test.object_id
# => 144328
:"test".object_id
# => 144328
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号