From: Eero Saynatkari Date: 2006-08-09T13:31:14+09:00 Subject: Re: For Float#class why is '===' different from '==' richB wrote: > richB wrote: >> I appreciate the responses. I'm still puzzled. It seems that "case a" >> is different from "case a.class" and that the comparison being done by >> "===" in when is influenced by the type/class of the when operand. >> >> I guess I wasn't expecting this. I am still trying to iron out my >> conceptual understanding. Is it that "case a" is asking about the >> object a, whereas >> "case a.class" is asking about the object/attribute a.class. Clearly a >> is Float but a.class is something else that evaluates to Float? >> > > What I mean to say is "a.class" is something that indicates "a" is a > Float, but "a.class" is not itself a Float value. Right. a.class is Float which is a constant. Float.class is Class. The #=== operator which I call the 'sorta' operator usually indicates some kind of a, er, kind-of, range or inclusion relationship. For example with Ranges, #=== tests whether a value is within the range. The most prominent use of #=== is the case expression which uses it to compare for equality--or inclusion--instead of the more traditional #==. This enables interesting usage of case. A particular implementation, Class#===, is of interest to you: a.class == Float # true Float === a # true ri Object#=== -- Posted via http://www.ruby-forum.com/.