Question: I am trying write a code to convert a word into phonetic alphabet. The desired return value should be something like this:

```
# >> Type your name and I will convert it to Phonetic Alphabets!
Kevin
# >> Kilo Echo Victor India November

```

I wrote a hash.

```
puts "Type your name and I will convert it to Phonetic Alphabets!"
name = gets.chomp
nato_keys =  {
    "A": "Alpha", "B": "Bravo",   "C": "Charlie",
    "D": "Delta",  "E": "Echo",    "F": "Foxtrot",
    "G": "Golf",   "H": "Hotel",   "I": "India",
    "J": "Juliett","K": "Kilo",    "L": "Lima",
    "M": "Mike",   "N": "November","O": "Oscar",
    "P": "Papa",   "Q": "Quebec",  "R": "Romeo",
    "S": "Sierra", "T": "Tango",   "U": "Uniform",
    "V": "Victor", "W": "Whiskey", "X": "X-ray",
    "Y": "Yankee", "Z": "Zulu"
  }

def nato()
    puts name.nato_keys.upcase().join(" ")
end

```

I have an issue with my method as it triggers an error.

Answer: 
You would want to do this:

```
name.chars.map { |x| nato_keys[x.upcase.to_sym] }.join(' ')

```

This `name.chars` give the enumeration with each character of the string `name`, `map` iterates on each character and transforms it to the instruction in the block.

block `{ |x| nato_keys[x.upcase.to_sym] }`, picks the relevant mapping for the character, but before that, it converts the key to uppercase and symbol(because in your `nato_keys`, keys are symbols). 'a' will become `:A`. 

After the block manipulation, we join the result with ' ' to give resultant string.
As Cary Swoveland says, the hash `nato_keys`, which really does not make sense, has to be converted to one that makes sense:

```
nato_keys.transform_keys!(&:to_s)

```

Given:

```
name = "Kevin"

```

then,

```
name.gsub(/(\A)?./){"#{" " unless $1}#{nato_keys[$&.upcase]}"}
# => "Kilo Echo Victor India November"

```