Coding is an Art

Anoiaque::Ergasterium

03/09/2010

Why :_:: == :_ is true in Ruby

The origin of this post is a tweet of PragDav Retweetted by Igrigorik (http://twitter.com/igrigorik/status/22767684142)
I've digged a bit to answer why :_:: == :_ is evaluated to true.

First, you can access to instance or class methods in ruby like this : Foo.new::say_hello => "Hello"

:_ is a symbol so an instance of Symbol class

So
:_ has methods(you can list it by :_::methods)

Therefore
:_:: == is the call to the method == of the instance :_ of the Symbol class

Therefore
:_::==:_ can be interpreted as == (:_, :_) where == is the method

As == (:_, :_) is true , :_::==:_ is true



QED

Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.
Alan Perlis


The best way to predict the future is to invent it.
Alan Kay


Ne découvre de nouvelles terres que celui qui sait quitter tout rivage.
André gide


Qui ne doute pas acquiert peu
Léonard de Vinci


Our life is frittered away by detail... simplify, simplify.
Henry David Thoreau