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

Project1

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

[已经解决] 关于实例对象的工作方法?

[复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止访问)

梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
帖子
3600
跳转到指定楼层
1
发表于 2015-10-23 18:39:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽

Lv3.寻梦者 (版主)

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

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

开拓者贵宾

来自 5楼
发表于 2015-10-23 19:44:07 | 只看该作者
本帖最后由 taroxd 于 2015-10-23 19:45 编辑
冷峻逸 发表于 2015-10-23 19:27
about how 实例对象 works
long long ago,I think ruby makes a variable in the ram.
but now, i think ...


Take ```b = A.new``` as an example.

A.new returns the *pointer* of a C *struct* that represented the instance. The struct includes the class of the instance, so that when we call ```A.new.a```, Ruby is able to find the method in A, the class of ```A.new```.

When we assign A.new to variable ```b```, Ruby inserts the reference to a table in the *binding*. The table is just like a hash, and what Ruby has done is like ```table["b"] = the pointer of A.new```. As we call ```b.a``` later, Ruby finds the pointer referenced by ```b```, gets the C struct that represents it, and thus knows all information about the object, such as its class and instance variables.

评分

参与人数 1星屑 +100 收起 理由
丿梁丶小柒 + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者 (版主)

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

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

开拓者贵宾

2
发表于 2015-10-23 19:16:55 | 只看该作者
Could you describe your problem in English and ruby? I cannot understand your Chinese.

评分

参与人数 1星屑 +233 收起 理由
VIPArcher + 233 你居然妄图理解猴子

查看全部评分

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止访问)

梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
帖子
3600
3
 楼主| 发表于 2015-10-23 19:27:33 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
451
在线时间
228 小时
注册时间
2015-2-23
帖子
241
4
发表于 2015-10-23 19:39:21 | 只看该作者
直接哈希啊,可以随便储存,随便赋值的啊!

点评

...  发表于 2015-10-24 08:44
a = Hash.new 这有实例又有对象啊!  发表于 2015-10-23 21:53
我是说实例对象  发表于 2015-10-23 19:52
制作XP特效,找我。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止访问)

梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
帖子
3600
6
 楼主| 发表于 2015-10-23 19:56:06 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 16:54

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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