From: Alexander Schofield Date: 2002-02-21T11:38:23+09:00 Subject: Re: confused about '::' vs '.' in method calls Not exactly: [/C/ruby]$ cat try.rb class C def self.cmeth puts 'class method' end def self.Ucmeth puts 'uppercase class method' end end C.cmeth C::cmeth C.Ucmeth C::Ucmeth() C::Ucmeth [/C/ruby]$ ruby try.rb class method class method uppercase class method uppercase class method try.rb:14: uninitialized constant Ucmeth at C (NameError) Raphael Clancy wrote: > > I must admit I'm a bit confused... probably because I never realy > understood the scope resoultion opperator when I learned C++, but I'm used > to seeing '::' when you want to show the scope of a method... Foo::Bar() > means Bar is a method in Foo called like so aFoo.Bar()... now in ruby, '::' > and '.' seem to be interchangeable... that is I can use both aFoo::Bar() > and aFoo.Bar() to call Bar on aFoo. In 'Ruby in a nutshell' Matz puts heavy > emphasis on using '::' for class methods, but the pick-axe book tends to > favor '.' Does it really matter which way you go? Are '::' and '.' > functionaly the same? Sorry if this is old hat, but I had a hard time > making google search the archive for '::' and '.' ;) > > Thanks! > > R. HTH -- Alexander Schofield