设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2147|回复: 3
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2761
在线时间
390 小时
注册时间
2015-8-8
帖子
439

R考场第七期纪念奖

跳转到指定楼层
1
发表于 2016-4-9 08:39:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

默默无闻的论坛观察者

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-28 06:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表