This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Other Languages and the fly likes Ruby: Range conditionals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "Ruby: Range conditionals" Watch "Ruby: Range conditionals" New topic

Ruby: Range conditionals

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The pragmatic guys book has this example. The input file is

input file


But the output I get is all six lines.

Any thoughts on what's not working?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
The Pickaxe, second edition, page 68, under heading 'Ranges as Conditions', specific to version 1.8:

In older versions of Ruby, bare ranges could be used as conditions in if, while, and similar statements. You could, for example, have written the previous code fragment as:

This is no longer supported. Unfortunately, no error is raised; the test will simply succeed each time.

So what you do is:

[ November 15, 2006: Message edited by: Guy Allard ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Thanks! My book and software are not on the same versions.
jQuery in Action, 3rd edition
subject: Ruby: Range conditionals
It's not a secret anymore!