Ruby the different between class and module

lhy20062008 · 2014年03月26日 · 1822 次阅读

class: 1、可以被实例化 2、用于创建对象 3、父类 module 4、成员包括:方法,常量,变量 5、方法包括:实例方法,类方法 6、可以被继承 7、不能 extend

module: 1、不能实例化 2、用于提供可重用方法,提供命名空间 3、父类 object 4、成员包括:方法,常量,类 5、方法包括:实例方法,module 方法 6、不能被继承,只能通过 include 被类和 module 引用 7、可以 extend

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号