Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Ruby: Range conditionals

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The pragmatic guys book has this example. The input file is

input file

output:

But the output I get is all six lines.

Any thoughts on what's not working?
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


Guy
[ November 15, 2006: Message edited by: Guy Allard ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! My book and software are not on the same versions.
 
Always! Wait. Never. Shut up. Look at this tiny ad.
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!