Michael W. Ryder wrote:
[...]
>.  I much prefer the
> simplicity of Basic and C with for loops that can go either direction.

That's because you're trying to write C in Ruby.  There are far more 
idiomatic ways of doing things -- and they *are* clearer, at least in a 
Ruby context.

> As far as going backwards I use it a lot to parse strings of the form
> "city name ST 12345-6789" to City, State, and Zip Code fields.  I look
> for the first blank from the end of the string and assume everything
> after it is the Zip Code, I then find the next two non-blank characters
> and assign them to State, and everything else is the City name.

That's great in a language like C that doesn't have very good string 
handling.  The Ruby way to do this would be
city, state, zip = string.split(/\s+/)

No incrementing.  No iteration.  Just a clear declarative syntax.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen / marnen.org
-- 
Posted via http://www.ruby-forum.com/.