ram*_*ion 10
这个语法在ruby中用于访问对象的元类或单例类.元类用于存储单个对象的方法.
obj = # whatever...
class <<obj
# here, self is defined as obj's metaclass
# so foo will be an instance method of obj's metaclass
# meaning that we can call obj.foo
def foo
# ...
end
end
# this is equivalent to the above
def obj.foo
# ...
end
Run Code Online (Sandbox Code Playgroud)
这是该语言的核心部分,并未在任何库中定义.