From: Nit Khair Date: 2008-10-23T21:12:07+09:00 Subject: Re: Is there a method_eval or similar thing ? Brian Candler wrote: > However you could turn it around and get the caller to pass a > pre-prepared hash containing all the bindings to askyn: > > askyn("Do you wish to proceed?", "n", > :yes => lambda { puts "user pressed yes" } > :no => lambda { puts "user pressed no" } > ) > That is something which immediately struck me as a possibility since I was considering putting some configurations into a hash anyway. askyn("Do you wish to proceed?", config = {}, &block) I had thought that would be ugly, and I might be missing something elegant and simple. However, perhaps that *is* the simple way to go. I'll do a check on your other options but keep them for future use. > > P.S. Note that if you nest def within a def, as your posted code does, > it probably doesn't do what you expect. The inner def will define a new > method in your object, at the time when the outer def is called. Actually, while generating code some time back, I had accidentally generated some methods within my run() and not noticed. The code had worked fine. I've rectified that, but used that "mistake" here! Thanks again. -- Posted via http://www.ruby-forum.com/.