2016年4月10日 星期日

instance_eval 與class_eval

instance_eval’s receiver must be an instance. and if an instance call instance_eval => mean you can define this instance’s singleton_method.
and because class is a instance of Class => so class also can call instance_eval => define this class’s singleton_method => class method

class_eval’s receiver must be an class. and if class call class_eval => you can define this class’s instance_method

instance_eval must be call by instance, use to define singleton_methods

class_eval must be call by class, use to define instance_methods 

沒有留言:

張貼留言