From: The Higgs bozo Date: 2008-12-13T03:07:46+09:00 Subject: Re: Function def at end of scripts No Where wrote: > I am refactoring an ugly script. I would like it contained all in one > file so I was moving code to functions/classes and put them at the end > of the script for legibility. This didn't work. They are only available > if I put them at the beginning of the script before I need them. Is > there a way to declare them at the beginning so I can put them all at > the end of the file? IIUC you want to do this, do_stuff(4, 5) def do_stuff(x, y) p x ; p y end which won't fly. However code running in the top-level scope is only suitable for the smallest of scripts anyway. I recommend: def main do_stuff(4, 5) end def do_stuff(x, y) p x ; p y end main -- Posted via http://www.ruby-forum.com/.