From: William Morgan Date: 2010-01-27T03:08:26+09:00 Subject: Re: Build a hash from ARGV, the Ruby way Reformatted excerpts from Toby Rodwell's message of 2010-01-25: > I suspect/hope there is a very simple "Ruby way" to do this, but I got > stuck thinking how to look ahead when iterating through ARGV. I've > got a bodged method of just taking pairs eg -a 1 -b 0 -c 3 etc, but it > would be nice to it properly. Any suggestions? All help appreciated! You can start doing something simple with ARGV.each_slice(2), but any kind of error checking quickly gets complicated. Trollop will do this exact thing for you (turn ARGV into a hash with error checking). -- William