Hi All,

Very new to learning Ruby, so please forgive if this is a moronic
question.

In Ruby, am I required to put my defs before any code that calls those
defs? I'm porting general skills across from PHP, where you can put a
function statement anywhere in a program, and the interpreter will
load the entire file before looking for the function definition.

In Ruby, it appears that defs have to come first? So, the following is
right:

def beforecode
   puts "appears before code that calls it"
end

beforecode

but this would be wrong?

aftercode

def aftercode
  puts "appears after code that calls it"
end

Any help appreciated!

Regards,

pt