Mercurial > repos > other > SevenLanguagesInSevenWeeks
view 1-Ruby/hashes.rb @ 97:85a5e9a6ef5c
Add more notes on extracting Just/Maybe values
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 30 Jun 2019 16:09:44 +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