Directionality of comparasion operators

Operators depend on context (think of the use of <). === is no
different. There are, after all, a limit to the symbols you want to
remember, right :slight_smile:

A number of symbols cannot be overridden during the interpretation of
a script/program, such as &&, ternary operator, assignment operators,
and several others.

When, I first saw ===, I immediately hit the docs out of curiosity,
having never seen it before, and therefore never had a problem with
it.

Todd

ยทยทยท

On Tue, May 27, 2008 at 6:34 AM, Tobias Weber <towb@gmx.net> wrote:

Hi,
maths says that the value of expressions like x == y and y == x is
always equal. And indeed most programmers wouldn't think twice about
using x < y instead of y > x (except maybe those versed in machine
language...).
But direction does matter in ruby, where operators are just messages
sent to the left operand. This often bites me when using ===.

Have you had bugs fixable by rotating an expression?

I like the moniker David Black cites: "the threequal operator."

///ark

ยทยทยท

On May 27, 2008, at 7:36 AM, Todd Benson wrote:

When, I first saw ===, I immediately hit the docs out of curiosity,
having never seen it before, and therefore never had a problem with
it.

It's cute, but I think it gives the wrong impression that === is
another form of ==, it's really not, since it's prime motivation is
use with the case statement, I think it's better to think of it has
having a meaning more like a general sense of 'matches'.

ยทยทยท

On Tue, May 27, 2008 at 10:48 AM, Mark Wilden <mark@mwilden.com> wrote:

On May 27, 2008, at 7:36 AM, Todd Benson wrote:

When, I first saw ===, I immediately hit the docs out of curiosity,
having never seen it before, and therefore never had a problem with
it.

I like the moniker David Black cites: "the threequal operator."

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Since case statements are traditionally about comparing values (in Cxx), I can buy that === is an extension of that. In any case, what's a better name? "The case matching operator" doesn't exactly trip off the tongue. :slight_smile:

But your point is taken.

///ark

ยทยทยท

On May 27, 2008, at 7:57 AM, Rick DeNatale wrote:

['threequal' is] cute, but I think it gives the wrong impression that === is
another form of ==, it's really not, since it's prime motivation is
use with the case statement, I think it's better to think of it has
having a meaning more like a general sense of 'matches'.

No, I don't think that

3 is like the range (0..5)
or
1.2 is like the class object Float

or
"abc" is like the regexp /.../ or /[abc]{3}/ or ...

perhaps === means something more like "recognizes as one of its own."

ยทยทยท

On Tue, May 27, 2008 at 11:14 AM, Tobias Weber <towb@gmx.net> wrote:

In article <481BDC1C-C183-43C0-80B0-CA2B5C50FFD2@mwilden.com>,
Mark Wilden <mark@mwilden.com> wrote:

Cxx), I can buy that === is an extension of that. In any case, what's
a better name? "The case matching operator" doesn't exactly trip off

= assignement
== equality
=== likeness?

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Except that likeness is commutative. If one thing is like another, then vice versa.

///ark

ยทยทยท

On May 27, 2008, at 8:14 AM, Tobias Weber wrote:

= assignement
== equality
=== likeness?