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

List:       ruby-talk
Subject:    Re: Is this old style Ruby?
From:       "Jason Voegele" <jason () jvoegele ! com>
Date:       2005-02-15 21:13:28
Message-ID: 10391.192.223.163.5.1108501991.squirrel () 192 ! 223 ! 163 ! 5
[Download RAW message or body]

Florian Gross said:
> And you can not use :: for accessing methods that start with an
> uppercase letter:

That's not exactly true:

irb(main):001:0> Integer("42")
=> 42
irb(main):002:0> Kernel.Integer("42")
=> 42
irb(main):003:0> Kernel::Integer("42")
=> 42

If you supply a parameter list (or even empty parentheses), ruby will use
:: for accessing methods with an uppercase letter, otherwise it will
assume you are trying to access a constant.

> irb(main):001:0> def Xing(); end; self::Xing
> TypeError: main is not a class/module

irb(main):013:0> self::Xing()
=> nil

-- 
Jason Voegele
"There is an essential core at the center of each man and woman that
remains unaltered no matter how life's externals may be transformed
or recombined. But it's smaller than we think."
    -- Gene Wolfe, The Book of the Long Sun


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

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