Hashes are created using curly brackets, to denote the start and end of a hash. An empty hash is simply '{}'.
emptyHash = {}A Hash can also contain key to value mappings when they are created, to initialize them. These mappings are set using either the rocket, which is =>, or a JavaScript style colon.
// mappings using the rocket
languages = {
:UK => 'English',
:France => 'French',
:Germany => 'German'
}
// mappings using a colon
stats = {
:hp : 50,
:attack : 10,
:defence : 30,
:mp : 100
}Alternatively you can call 'new Hash()' instead of using the curly braces. The result is exactly the same.
aHash = {}
anotherHash = new Hash()