From: Lloyd Zusman Date: 2004-07-31T04:56:47+09:00 Subject: Re: Forward references? "Robert Klemme" writes: > "Lloyd Zusman" schrieb im Newsbeitrag > news:d62dd0tu.fsf@asfast.com... >> Is there a way to define forward references to functions? Due to my own >> personal eccentricities, I like to have the main body of a program >> appear at the top of its source file, and the functions it uses at the >> end. >> >> [ ... ] > > Just define them duplicately, the first time with an empty body: > > # "prototypes" > def foo;end > def bar(name)end > > # main stuff > x = foo() > y = bar() > puts x > puts y > exit 0 > > # "functions" > def foo > # foodoo > end > > def bar(name) > # bardo > end > Thank you very much, but this doesn't appear to work. Here's what I tried: def foo;puts "forward ref of foo";end def bar(arg);puts "forward ref of bar(#{arg})";end foo() bar('abc') exit(0); def foo puts "foo" end def bar(arg) puts "bar: #{arg}" end When I ran it, it produced the following output: forward ref of foo forward ref of bar(abc) In other words, the second function definitions did not override the first ones. -- Lloyd Zusman ljz@asfast.com God bless you.