查看: 2369|回复: 3

[已经过期] 请问":"是什么玩意

[复制链接]
梦石
0
星屑
3130
在线时间
419 小时
注册时间
2015-8-8
回帖
371

R考场第七期纪念奖

发表于 2016-4-9 08:39:35 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
一开始还以为是取消应用序,但是如果我引用:函数的话,输出的就是这个函数的名字了。
旧作《邵彦朝的大冒险》下载

默默无闻的论坛观察者

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2016-4-10 07:09:53 | 显示全部楼层
本帖最后由 taroxd 于 2016-4-10 07:15 编辑


Symbol objects represent names and some strings inside the Ruby interpreter. They are generated using the :name and :"string" literals syntax, and by the various to_sym methods. The same Symbol object will be created for a given name or string for the duration of a program's execution, regardless of the context or meaning of that name. Thus if Fred is a constant in one context, a method in another, and a class in a third, the Symbol :Fred will be the same object in all three contexts.

module One
  class Fred
  end
  $f1 = :Fred
end
module Two
  Fred = 1
  $f2 = :Fred
end
def Fred()
end
$f3 = :Fred
$f1.object_id   #=> 2514190
$f2.object_id   #=> 2514190
$f3.object_id   #=> 2514190

点评

哦哦明白了谢谢  发表于 2018-9-17 17:53
请讲汉语  发表于 2016-4-10 10:10
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部