Ruby supports two forms of objectified methods. Class Method is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method. Ruby also supports unbound methods, which are method objects that are not associated with a particular object. These can be created either by calling unbind on a bound method object or by calling Module#instance_method. Unbound methods can be called only after they are bound to an object. That object must be a kind_of? the method’s original class.
Ruby中不会发生,也不存在function.fun这种调用方式,只有对象才可以接收消息,而def的方法显然还不是一个对象
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |