On 11/9/06, Sean Hussey <seanhussey / gmail.com> wrote:
> Actually, let me step back.  This is really good, but what if I wanted
> named parameters instead?  Or is there a way to split a line and load
> it into a hash and pass that?
>
> The file doesn't have header information, but I know what the order of
> the fields will be.  I guess I could just write a method, pass the
> line to it for parsing, and return a hash.  Would that be about right?

KEYS = %w[ name id phone color temperature dog password ]

data = line.chomp.split(...)
hash = Hash[*(KEYS.zip(data))]