From: dblack@... Date: 2007-07-25T00:45:21+09:00 Subject: Re: case equality question Hi -- On Tue, 24 Jul 2007, Kaldrenon wrote: > On Jul 24, 10:28 am, Sebastian Hungerecker > wrote: >> Only if b is a class. If b is e.g. a range or an array, it checks whether b >> includes a. If b is a regex it checks whether b matches a. For many other >> things it's just the same as b==a. > > Okay, that's a more logical way of thinking about it, thank you. See, > I was looking at === as equivalent to Java's instanceof keyword, but I > can see now that that's not all === does. === is a method, so its behavior is completely programmable per class or per object. That's why you get things like: /abc/ === "abcdef" # true One fairly generalized way to read a === b is: a is the case of b. You might need to embellish it a bit, but it gives you a start: (matching) /abc/ is the case of "abcdef" (being an instance of) String is the case of "abc" etc. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)