This is one of solution to this problem.
a=[];$<.map{|l|l=='0'?($><<a.pop):a<<l}
I run it on a terminal but it displays no output.
Where has $> which is $DEFAULT_OUTPUT gone?
I used p $> etc but it does not output the result.
How can I display the result of $> on a terminal?
$>works fine, the problem is elsewhere.The real culprit is
$<(which isARGF). When you run$<.each { }in the terminal, there are no args forARGFand it hangs waiting for them.If you put this in a file and ran it with command line arguments, or piped in the arguments from something else, it would probably do what you expect.
If you replace
$<with an array, it seems to work.