首页 > 代码库 > ruby类名之间<,<=方法
ruby类名之间<,<=方法
有时候看源码的时候看到类名之间存在<.<=操作,顿时一头雾水,类名之间也可以比较吗?查了下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类名之间<,<=方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。