From: Hal Fulton Date: 2004-08-21T04:45:10+09:00 Subject: Re: Neat trick for Steckerboard of Enigma needed... Hal Fulton wrote: > Meino Christian Cramer wrote: > >> So I get a string, for example "AGQTRXDF" into the simulator. >> Does anyone of the Ruby gurus here know a neat trick to convert >> this into a hash of the form >> steckers={ >> "A" => "G", >> "Q" => "T", >> "R" => "X" >> "D" => "F" >> } in "one turn"? I only know a very "unrubyish" way to do >> this in >> single steps -- kinda "slow motion" programming... ;) > > > Would this work? > > hash = Hash.new(*string.split(/./)) Ah, no, sorry. Make that: hash = Hash.new(*string.split("")) Hal