D
Daly
Hello all,
If I have a class such as:
class Example
def one
puts "one"
def two
puts "two inside one"
end
end
def two
puts "two inside Example"
end
end
And I do:
e = Example.new
e.one
e.two
I get, obviously:
one
two inside one
What I don't understand is that if after that I do:
f = Example.new
f.two
I still get:
two inside one
Since the two method in question is defined within one, doesn't it
behave like a method on the object e? How can it override the two
method outside for the f object?
Thanks for your help in explaining this.
If I have a class such as:
class Example
def one
puts "one"
def two
puts "two inside one"
end
end
def two
puts "two inside Example"
end
end
And I do:
e = Example.new
e.one
e.two
I get, obviously:
one
two inside one
What I don't understand is that if after that I do:
f = Example.new
f.two
I still get:
two inside one
Since the two method in question is defined within one, doesn't it
behave like a method on the object e? How can it override the two
method outside for the f object?
Thanks for your help in explaining this.