From: Kevin Brown Date: 2005-12-22T13:38:29+09:00 Subject: Re: String > Integer Conversion Problem On Wednesday 21 December 2005 22:26, J. Ryan Sobol wrote: > On Dec 21, 2005, at 11:20 PM, James Edward Gray II wrote: > >> one, two = ARGV.map{ |n| Integer(n) } > > Excuse my ruby "newb-ness", but what does this line actually do? > Mainly, what's throwing me off is the "one, two" assignment (or > whatever it is). Try: irb(main):001:0> one, two = 3, 4 => [3, 4] irb(main):002:0> one => 3 irb(main):003:0> two => 4 It's a multiple assignment. It takes multiple values (or an array) and spits them into what's on the left. Map simply iterates through an array and runs the block (the thing in braces) each item, storing the result. Thus, we're converting everything in the ARGV array to an integer and stuffing it into two variables. The reason everyone else was saying it would be a good idea to check the length is the following: irb(main):004:0> one, two = 3, 4, 5 => [3, 4, 5] irb(main):005:0> one => 3 irb(main):006:0> two => 4 Kinda bad to have mysteriously disappearing command line arguments. :-) Play around with it and I'm sure you'll get the hang of it. Oh, and welcome to Ruby! :-D