From: Gijs Nijholt Date: 2006-10-21T07:14:49+09:00 Subject: Re: multi dim array? hm, tried several things with detect() and they all gave a nil error when least expected error.. so I thought maybe I need to switch to Hash instead of Array? excuse me for posting the entire function, but this is what I've made of it: def translate_to_braille(msg) #braille_alphabet = [ ["a","⠁"], ["b","⠃"], ["c","⠉"], ["d","⠙"], ["e","⠑"], ["f","⠋"], ["g","⠛"], ["h","⠓"], ["i","⠊"], ["j","⠚"], ["k", "⠅"], ["l","⠇"], ["m","⠍"], ["n","⠝"], ["o","⠕"], ["p","⠏"], ["q","⠟"], ["r","⠗"], ["s","⠎"], ["t","⠞"], ["u","⠥"], ["v","⠧"], ["w","⠺"], ["x","⠭"], ["y","⠽"], ["z","⠵"], [" ", " "] ] braille_alphabet = { "a"=>"⠁", "b"=>"⠃", "c"=>"⠉", "d"=>"⠙", "e"=>"⠑", "f"=>"⠋", "g"=>"⠛", "h"=>"⠓", "i"=>"⠊", "j"=>"⠚", "k"=>"⠅", "l"=>"⠇", "m"=>"⠍", "n"=>"⠝", "o"=>"⠕", "p"=>"⠏", "q"=>"⠟", "r"=>"⠗", "s"=>"⠎", "t"=>"⠞", "u"=>"⠥", "v"=>"⠧", "w"=>"⠺", "x"=>"⠭", "y"=>"⠽", "z"=>"⠵", " "=>" " } #msg.split(//).inject("") { |result, char| result += braille_alphabet.first } msg.split(//).inject("") { |result, char| result += char + " " + braille_alphabet["r"] } end the braille_alphabet["r"] nicely gives it's value, but when I replace it with braille_alphabet[char] Ruby says: can't convert nil into String why? char is not nil, because when I print it, it contains a character.. Wilson Bilkovich wrote: > On 10/20/06, Gijs Nijholt wrote: >> end >> > Does: > some_alphabet.detect {|e| e == "c"}[1] > ..do what you're looking for? -- Posted via http://www.ruby-forum.com/.