| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 18 |
| 经验 | |
| 最后登录 | 2020-8-1 |
| 在线时间 | 2161 小时 |
酱油的
- 梦石
- 0
- 星屑
- 1840
- 在线时间
- 2161 小时
- 注册时间
- 2007-12-22
- 回帖
- 3216

|
发表于 2008-7-7 06:07:58
|
显示全部楼层
基本上沒有分別,名字不是重點 = =
所謂屬性,只是從來外部操作內部變量的方法。具體如同
attr_***
或者
def a
return @a
end
一類的方法。其實用 .instance_variable_set(string) 和 .instance_variable_get(string, value)
就可以。
以上太深奧就漠視 = =
重點只是這個
class NewClass
def method1
p 'You are using a method'
end
end
a = NewClass.new
a.method1 #=>'You are using a method'
就是這樣了 ... |
|