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?
Why does Ruby keep picking on me? Oh, wait. The principle of least
surprise - all programming languages infuriate me, therefore it would
surprise me least if Ruby did too.
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?
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