From: MonkeeSage Date: 2007-12-07T17:00:31+09:00 Subject: Re: Newbie ruby wonderment. On Dec 6, 10:16 pm, araminska wrote: > > Ruby, like Perl, reads the code line by line, the same as you write it.. > > Sorry, but I have to disagree. (That is, if you are saying that Perl has > to have the subs first, also. Not sure you are.) > > With perl > > print_form() > > sub print_form { > #... do stuff > > } > > works just fine. I have always put the subs at the bottom and the calling > code at the top. > > But you are right and I was wrong about Ruby. Methods DO have to be > defined before use. Not sure what I did before to think they don't. Perl > and Ruby obviously have different compiling structures. > > No biggie. I just have to remember that till it becomes natural. > > Araminska Seems that perl parses the entire file first, before it runs any code. In most interpreted languages (ruby, python, lua, javascript, php, &c), the code is executed as soon as an expression is parsed, so it is an error to call a function before you define it. Ps. Hope you enjoy using ruby. :) Regards, Jordan