ruby "==" "equal"

作者: Leon&CC
发布时间:2015-07-13 11:31:37

The == comparison checks whether two values are equal

== 用来比较两个值是否相等

eql? checks if two values are equal and of the same type

eql? 检查两个值是否相等,类型是否一致

equal? checks if two things are one and the same object.

equal? 用来检查两个数是否是同一个实体(内存中的地址否是相同)


=== :用来检测类型是否一致

如String === "测试" #=>true   #注意!类型或正则表达式必须位于左边

标签: Ruby
来源:http://www.cnblogs.com/leon19870907/archive/2011/04/12/20137

推荐: