Logan Capaldo
2/9/2006 12:36:00 AM
On Feb 8, 2006, at 7:16 PM, charlie bowman wrote:
> The following code works but it's awfully ugly putting a method at the
> top of a script. Is this really how I have to structure a script?
Well yes and no. If you stick display_bad_action in the TimeKeeper
class it doesn't matter whether you call it from another method
before it "sees" the definition. The rule is, before you call a
method (at runtime chronologically, not necessarily before you type
the code to call the method) it must be defined.
so
class A
def a
b
end
def b
puts "B called"
end
end
a = A.new
a.a
is fine.