From: "Ara.T.Howard" Date: 2004-01-22T04:54:59+09:00 Subject: Re: Modules as namespace On Thu, 22 Jan 2004, Yukihiro Matsumoto wrote: > Date: Thu, 22 Jan 2004 03:31:05 +0900 > From: Yukihiro Matsumoto > Newsgroups: comp.lang.ruby > Subject: Re: Modules as namespace > > Hi, > > In message "Re: Modules as namespace" > on 04/01/22, Hal Fulton writes: > > |Second of all, I think you need parens because of a > |precedence issue: > | > | foo = (My::Little::Namespace::Foo).new? > > No, parens are not required. Ruby parser is smart enough to read your > intention (this case at least). > > matz. really? what am i missing? ~ > cat foo.rb attempts = lambda do module A::B::C class Foo; end end A::B::C::Foo.new end, lambda do module A module B module C class Foo; end end end end A::B::C::Foo.new end attempts.each do |block| begin p block.call rescue Exception => e p e end end ~ > ruby foo.rb # # -a -- ATTN: please update your address books with address below! =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | STP :: http://www.ngdc.noaa.gov/stp/ | NGDC :: http://www.ngdc.noaa.gov/ | NESDIS :: http://www.nesdis.noaa.gov/ | NOAA :: http://www.noaa.gov/ | US DOC :: http://www.commerce.gov/ | | The difference between art and science is that science is what we | understand well enough to explain to a computer. | Art is everything else. | -- Donald Knuth, "Discover" | | /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' ===============================================================================