From: William James Date: 2007-12-06T18:20:54+09:00 Subject: Re: Lambda funcs that call gets won't halt program execution? On Dec 5, 4:30 pm, 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? If Ruby is invoked in this fashion ruby myprog.rb myfile then gets reads from the file. You need $stdin.gets