D
David Espada
Hi.
I have a question about constants in Ruby. Look at this code:
-------------------------------------
class Pepo
POPORRES = 4
def self.pepo(&block)
Pepo.new(&block)
end
def initialize(&block)
instance_eval(&block)
end
end
Pepo.pepo do
puts POPORRES
end
-------------------------------------
When executing, it fails with erro 'uninitialized constant POPORRES'. If proc
executes in Pepo class context, why it fails so?
Thank you very much for your aclarations.
Greets.
I have a question about constants in Ruby. Look at this code:
-------------------------------------
class Pepo
POPORRES = 4
def self.pepo(&block)
Pepo.new(&block)
end
def initialize(&block)
instance_eval(&block)
end
end
Pepo.pepo do
puts POPORRES
end
-------------------------------------
When executing, it fails with erro 'uninitialized constant POPORRES'. If proc
executes in Pepo class context, why it fails so?
Thank you very much for your aclarations.
Greets.