From: Tomas Pospisek's Mailing Lists Date: 2007-12-06T07:52:32+09:00 Subject: Re: Lambda funcs that call gets won't halt program execution? On Thu, 6 Dec 2007, Peter Bunyan wrote: > Once again, a problem with my Befunge interpreter. I'm trying to > implement the ~ and & functions - get a character and a number, > respectively. My & function looks like this: > instructions["&"] = lambda { print "Number: "; stack.push > gets().strip.to_i} > > But it complains about gets() being nil. as soon as the function is run. > Well, of course it is. It has let me type. Is there anyway to make it > halt? This works for me: i= {} s= [] i["&"] = lambda { print "Number: " s.push( gets().strip.to_i ) } i['&'].call puts "Evaluating stack: #{s.pop}" Gives: -> Number: 123 -> Evaluating stack: 123 *t -- ----------------------------------------------------------- Tomas Pospisek http://sourcepole.com - Linux & Open Source Solutions -----------------------------------------------------------