Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4286
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Scope problem (?) in implementing Design Patterns in Ruby |
| Date | 2011-05-11 14:28 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <2ac328808edcaa956da4f286617acefb@ruby-forum.com> (permalink) |
| References | <7e6155b0-8d33-4677-87ec-be2c3f0fca97@b7g2000prg.googlegroups.com> |
RichardOnRails wrote in post #998059:
>
1) Your case statement syntax doesn't work in ruby 1.9.2:
prog.rb:4: syntax error, unexpected ':', expecting keyword_then or ','
or ';' or '\n'
You have to use 'then' in place of a colon.
2) Next, I get this error:
prog.rb:67:in `evaluate': uninitialized constant Not::All (NameError)
from prog.rb:74:in `<main>'
which relates to this code:
class Not < Expression
def initialize(expression)
@expression = expression
end
def evaluate(dir)
all = All.new.evaluate(dir)
other = @expression.evaluate(dir)
all - other
end
end
In ruby, constants are looked up like directories and files. When you
are inside the Not class (which is a module), the 'directory' you are in
for constant lookups is the 'Not' directory. When you write All.new,
because the name All is not preceded by a directory name, ruby looks in
the current 'directory' for the constant All. The current directory is
Not, so ruby is looking for Not::All, i.e. the 'file' All in the
'directory' Not. However, All is not defined inside Not, so you get an
error. In fact, there is not constant named All defined anywhere in
your program.
--
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