From: Jamis Buck Date: 2004-08-21T04:50:05+09:00 Subject: Re: Neat trick for Steckerboard of Enigma needed... Hal Fulton wrote: > 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, This one still isn't working for me. I keep getting an empty hash back. Isn't the parameter to Hash.new used as the return value for when a query misses? - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."