Given the example:
def method_of_doom my_string = "I sense impending doom." my_string.ah_ha_i_called_a_nonexistent_method rescue NoMethodError => e: puts "PROBLEM: " + e.to_s rescue Exception: puts "Uhh...there's a problem with that there method." end On the line where it says:
rescue NoMethodError => e: What is the '=>' doing?
How is it different than this usage:
module FighterValues BAMBOO_HEAD = { 'life' => 120, 'hit' => 9 } DEATH = { 'life' => 90, 'hit' => 13 } KOALA = { 'life' => 100, 'hit' => 10 } CHUCK_NORRIS = { 'life' => 60000, 'hit' => 99999999 } def chuck_fact puts "Chuck Norris' tears can cure cancer..." puts "Too bad he never cries." end end module ConstantValues DEATH = -5 # Pandas can live PAST DEATH. EASY_HANDICAP = 10 MEDIUM_HANDICAP = 25 HARD_HANDICAP = 50 end puts FighterValues::DEATH → {'life'=>90,'hit'=>13} puts ConstantValues::DEATH → -5
rescue Exception-Exceptioncan include really severe errors. (Not criticising you, just the author of the tutorial).