Mercurial > repos > other > SevenLanguagesInSevenWeeks
view 1-Ruby/hashes.rb @ 29:9c7af76fdbd0
Print isn't PrinLn, so add some \n characters to the output
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 06 Sep 2017 18:36:02 +0100 |
parents | ebb19742b98f |
children |
line wrap: on
line source
#! /usr/bin/env ruby # Ruby has inline hashmap definitions, like PHP. # Java doesn't. C# isn't quite as clear as this "key => value" pattern. frenchify = { 'one' => 'un', 'two' => 'deux' } puts frenchify['one'] # Or, done properly with symbols: frenchify = { :one => 'un', :two => 'deux' } puts frenchify[:one] # But what is a symbol? Its own class, apparently! puts :one.class