From: "David A. Black" Date: 2009-02-07T21:49:21+09:00 Subject: Re: Module#=== vs Object#is_a? On Sat, 7 Feb 2009, Peter Fitzgibbons wrote: > HI All, > > Could somone explain the subtle difference between Module#=== and > Object#is_a? > > I found a usage of === to test if an argument is Regexp or not... just want > to know the restrictions. > The code is beautiful... > > if Regexp === regexp_or_string They're the same, in essence. === is bound to the C method rb_mod_eqq, which looks like this: static VALUE rb_mod_eqq(VALUE mod, VALUE arg) { return rb_obj_is_kind_of(arg, mod); } === is usually a light wrapper around something, mainly so that the case construct can use it implicitly. (It always looks a bit odd to me used explicitly, since it usually has semantics that don't relate to anything that equal signs normally signify.) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!