[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

different between Door::new and Door.new

Ming en Chia

4/8/2007 5:55:00 AM

may i know what is the different between Door::new and Door.new
i seem to work the same.

--
Posted via http://www.ruby-....

1 Answer

Florian Groß

4/8/2007 11:24:00 AM

0

The :: operator and the . operator only behave differently when
constants are involved AFAIK.

Foo::Bar will only look for the constant and raise an exception
otherwise.
Foo::Bar() and Foo::Bar X will only look for a method.
Foo.Bar will only look for a method.

Otherwise the :: operator is equivalent to the . operator, even for
non-module/class objects:

5::to_s # => "5"
5::+ 6 # => 11