首页 > 其他 > 详细

ruby类名之间<,<=方法

时间:2014-09-23 18:22:16      阅读:206      评论:0      收藏:0      [点我收藏+]

有时候看源码的时候看到类名之间存在<.<=操作,顿时一头雾水,类名之间也可以比较吗?查了下api,豁然开朗

Class的父类是Module,Module.methods.grep(/</)

 

会得到匹配的结果集:[:<=>,:<,:<=]

e.g

mod < other → true, false, or nil

Returns true if mod is a subclass of other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A<B” implies “A<B”).

mod <= other → true, false, or nil

Returns true if mod is a subclass of other or is the same as other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A<B” implies “A<B”).

 

ruby类名之间<,<=方法

原文:http://www.cnblogs.com/timsheng/p/3988886.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!