Ruby Hash Colon don't seem to work


#1

I was trying to test out some really simple code.

DIAL_BOOK = {
    "eastbay": 510,
}

city = gets.chomp

puts “Area Code: #{DIAL_BOOK[city]}”

when I type in eastbay from the terminal, the program doesn’t return me 510. The weird thing is if I switch the colon with => all suddenly it works. I was told the colons in hash are now valid but I don’t get why it’s not working in Cloud9.


#2

I’ve always used =>, but if this is true then you might want to check your Ruby version in your workspace.


#3

Thanks that worked. I guess I have a lot to learn about Ruby