From: Robert Klemme Date: 2007-09-19T06:55:03+09:00 Subject: Re: Newbie: what's Ruby idiom for word-by-word input? On 18.09.2007 20:13, Alex Shulgin wrote: > On Sep 18, 3:30 am, William James wrote: >> But, dang it all, I'm gonna say you're cheating because >> you're still reading lines behind the scenes! >> Reading lines and breaking them into words is a lot >> easier than reading characters and constructing words. > > Yeah, that is my point. I only see a way to do this efficiently (w/o > reading the whole lines) by writing the routine in C and then using it > in Ruby. Why do you think Ruby solutions are inefficient? If you fear that reading individual characters is slow in Ruby: even if you use #getc Ruby will do buffered IO (I'm not sure about $stdin though). > Anyway, I probably won't bother, since there is no real problem--just > curiosity of mine. ;-) If you are curious why not just take the suggested implementations and benchmark them. Benchmarking is actually pretty easy in Ruby because there is module Benchmark already (plus some more advanced variants). > Thanks all for discussing, Thank you for bringing up interesting subjects! Kind regards robert