assignment to variables from ARGV array on one line
I have just discovered that you can do this
# lets say ARGV has 3 items [1, 2, 3] # the following: a, b, c = ARGV # will make this #=> a=1, b=2, c=3
I didn’t know you can do this. I just ready it in one of the examples somewhere and I can’t find it.
Nice way of procesing not only ARGV but other arrays.
#So, this is how I can ship my data in Watir scripts. # Write out: ARGV.clear ARGV << 'a1' << 'b2' << 'c3' # # read from: a, b, c = ARGV # of course I could use main gem or other option parsers # but ARGV is a good simple choice
Comments (1) to “assignment to variables from ARGV array on one line”
Post a Comment
You must be logged in to post a comment.
Alister Scott wrote:
I love this feature of ruby. This is how you return (and catch) multiple values from a ruby method.
Posted on 12-Jun-08 at 3:34 am | Permalink