Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4297
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Scope problem (?) in implementing Design Patterns in Ruby |
| Date | Wed, 11 May 2011 15:45:39 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 56 |
| Message-ID | <f075a5f4506fda4a5fdf3adea6040bee@ruby-forum.com> (permalink) |
| References | <7e6155b0-8d33-4677-87ec-be2c3f0fca97@b7g2000prg.googlegroups.com> <2ac328808edcaa956da4f286617acefb@ruby-forum.com> <4bfa1e5a3794daf70f5171094052dab0@ruby-forum.com> <BANLkTi=qTAcJXkTeKSEeGDZeHs_Ma+pXUA@mail.gmail.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1305146774 48944 65.111.164.187 (11 May 2011 20:46:14 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Wed, 11 May 2011 20:46:14 +0000 (UTC) |
| In-Reply-To | <BANLkTi=qTAcJXkTeKSEeGDZeHs_Ma+pXUA@mail.gmail.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 383009 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <f075a5f4506fda4a5fdf3adea6040bee@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:4297 |
Show key headers only | View raw
David Jacobs wrote in post #998093:
> I think the lookup starts at the innermost scope but since All isn't
> defined
> in Not, it reaches the top-level.
Yes, you are right:
1)
===
Constants defined within a class or module may be accessed unadorned
anywhere within the class or module.
(Programming Ruby)
===
2)
===
Constants declared outside of a class or module are assigned global
scope.
(http://www.techotopia.com/index.php/Ruby_Variable_Scope#Ruby_Constant_Scope)
===
So it's a case of the inner All hiding the global All. And you can use
the :: prefix to leap over an inner scope constant that hides a toplevel
constant:
class All
def greet
puts 'All#greet'
end
end
module C
class All
def greet
puts "C::All#greet"
end
end
class Dog
def do_stuff
::All.new.greet #<*****
end
end
end
C::Dog.new.do_stuff
--output:--
All#greet
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-11 10:15 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-11 12:52 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-11 12:53 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-11 13:37 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-11 18:07 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-11 17:30 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 14:28 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 15:23 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-11 15:26 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 15:45 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 15:34 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-11 15:48 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-12 08:59 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-12 20:56 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-12 21:11 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-12 21:18 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-13 00:28 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-13 09:46 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-13 10:55 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-13 12:50 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby Steve Klabnik <steve@steveklabnik.com> - 2011-05-13 13:14 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-23 19:24 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-24 20:33 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-25 17:30 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> - 2011-05-27 22:08 -0700
Re: Scope problem (?) in implementing Design Patterns in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-12 21:20 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby David Jacobs <developer@wit.io> - 2011-05-12 21:26 -0500
Re: Scope problem (?) in implementing Design Patterns in Ruby Ryan Davis <ryand-ruby@zenspider.com> - 2011-05-13 12:29 -0500
csiph-web