ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  Building Unix Tools with Ruby
Subject:   from String to Integer
Date:   2004-07-13 03:41:08
From:   Mailinator
On the second page of the article, the author converts the elements of the array named extract_args (or remove_args) from Strings to Integerss. You can do it in a Rubier way with the Array#collect method, like:

when '--extract'
extract_f = true
extract_args = arg.split(',').collect { |column| column.to_i }
# ...

And you can do the same with the when '--remove' clause of the switch.