xiaohesong / TIL

本库记录每日所学,README是一些链接;学习是自己的事。
http://t.cn/EP1BKKb
297 stars 67 forks source link

[每日见闻-2017-07-20]关于self的小细节 #3

Closed xiaohesong closed 6 years ago

xiaohesong commented 7 years ago

class Foo attr_accessor :name def initialize(x) self.name = "wo" end end

f = Foo.new(3) puts f.name


再比如
```ruby
class A
  @num = 8
  def show
    puts @num
  end
end

class B < A
  def initialize
    @num = 3
  end
end

b = B.new
b.show
xiaohesong commented 7 years ago

在线学习网站,温故而知新