From: Brian Candler Date: 2011-12-12T01:32:28+09:00 Subject: Re: How can i make this procedure into a function? Akvile K. wrote in post #1036147: > what i need is that this procedure works in a programm that chsnges the > lights in a traffic light. i am using timer now but i am 100% sure that > my professor during the exam wants to see a function or a procedure in > this programm. If that's really the case then your professor doesn't know much about ruby. Ruby has neither procedures nor functions - it has methods. (You could count lambdas as being another type of callable too) In some imperative languages, the only difference between a procedure and a function is whether it returns a value or not. So by that definition, a method in ruby will substitute for either. Now, if you are going to define a method, I suggest you do it *outside* a block. e.g. def mymethod(x,y,z) ... end Shoes.app do ... all this is a block mymethod(a,b,c) ... etc end This is because a block is essentially a bit of callback code, to be executed zero, one or more times by the method it is passed to (Shoes.app here). So if you use 'def' within a block, you may end up defining the same method lots of times. -- Posted via http://www.ruby-forum.com/.