From: Louis-Philippe Date: 2009-06-03T23:16:39+09:00 Subject: Re: block as string --0016e6471b0aadef1b046b724ea4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thanks Brian, It's a neat trick! I'll remember it! I'm not sure I'll use it though, as it require you define the function inside a string... a bit cumbersome. what I need is some sort of macro system (the LISP macro, not the C one), to parse the block before calling it. I was thinking to make it a string, then parsing with regex, would have done it... but seems not. I'll work out an other logic around the problem then ;). L-P 2009/6/3 Brian Candler > Louis-Philippe wrote: > > any other idea? > > Well, you can remember the string form at the time you define the > lambda. > > def fn(str) > res = eval "lambda { #{str} }" > class < res > end > > a = fn "|x| puts x+x" > a["Hello"] > puts a.source > -- > Posted via http://www.ruby-forum.com/. > > --0016e6471b0aadef1b046b724ea4--