• 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic