We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
self
initialize
class Foo def initialize(x) self.c x end def c(x) puts "c的参数是#{x}" end end f = Foo.new(1)
self == @ !self.eql?(@)
类似于coffee js的
coffee js
this && @
例如:
class Foo attr_accessor :name def initialize(x) @name = "wo" end end class Foo attr_accessor :name def initialize(x) self.name = "wo" end end f = Foo.new(3) puts f.name
再比如
class A @num = 8 def show puts @num end end class B < A def initialize @num = 3 end end b = B.new b.show
The text was updated successfully, but these errors were encountered:
在线学习网站,温故而知新
Sorry, something went wrong.
No branches or pull requests
self
在当前的initialize
中直指当前的实例对象self
在很大程度上类似.都是指定当前的实例.给我的感觉就是类似于
coffee js
的例如:
再比如
The text was updated successfully, but these errors were encountered: