直接上代码:
module M
# 一个普通的实例方法
def mul
@x * @y
end
module ClassMethods
# 一个类方法
def factory(x)
new(x, 2 * x)
end
直接上代码:
module M
# 一个普通的实例方法
def mul
@x * @y
end
module ClassMethods
# 一个类方法
def factory(x)
new(x, 2 * x)
end