[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Is this old style Ruby?
From:       YANAGAWA Kazuhisa <kjana () dm4lab ! to>
Date:       2005-02-15 23:23:53
Message-ID: 20050215232343.6E7361EE17 () milestones ! dm4lab ! to
[Download RAW message or body]

In Message-Id: <1108477682.487306.150420@c13g2000cwb.googlegroups.com>
centrepins@gmail.com writes:

> It seems a little bit odd to me to have two ways of doing the same
> thing.  Seems best (as was mentioned above) to stick to :: for module
> access and . for everything else.  ??

For consistency use ".", for uniformity with other languages use
"::".  Historically Foo::foo() notation was introduced for those who
said that could be more understandable for C++ or Java people.

For my own preference, I use "." since that consistent in Ruby ---
in Foo.foo, receiver is Foo itself --- and "::" notation always needs
() if method name is capitalized.

# Well, capitalized name of class methods also out of my preference....

    > ruby
    class Foo; def self.foo; p :foo; end; end
    Foo.foo
    Foo::foo
    :foo
    :foo
    > ruby
    class Foo; def self.Bar; p :bar; end; end
    Foo.Bar
    Foo::Bar
    :bar
    -:3: uninitialized constant Foo::Bar (NameError)


-- 
kjana@dm4lab.to                                      February 16, 2005
Better late than never.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic