Last active
October 20, 2023 20:41
-
-
Save mikedamage/105081 to your computer and use it in GitHub Desktop.
Morse code dictionary as a Ruby Hash object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
morse_dict = { | |
"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" => "--..", | |
" " => " ", | |
"1" => ".----", | |
"2" => "..---", | |
"3" => "...--", | |
"4" => "....-", | |
"5" => ".....", | |
"6" => "-....", | |
"7" => "--...", | |
"8" => "---..", | |
"9" => "----.", | |
"0" => "-----" | |
} | |
Thank you, kind soul.
ty
Thank you!! :)
I forgot I even posted this. I was a wee baby coder back then. I updated it to make a bit more sense.
Thank you man!! I am a baby coder right now! 🤣
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In at least version 2.1.2 of Ruby, this doesn't work. The Hash should be put together using square brackets instead of
new
. So it should look like this...