>> whichcase("1") => "I am a string." >> whichcase(3) => "I am either 2 or 3." >> whichcase(4) => "I belong to a range." >> whichcase(8) => "I belong to a range." >> whichcase(20) => "I am 20!" >> whichcase(:nobody) => "I am nobody." irb def whichcase(num) case num when 1 "I am an integer." when "1" "I am a string." when 2, 3 "I am either 2 or 3." when 4..10 "I belong to a range." when ->(x) { x == 20 } "I am 20!" else "I am nobody." end end
! >> %w(hello world).map(&:upcase) => ["HELLO", "WORLD"] #10 Symbol to Proc to Block irb http://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean
>> OneAndOnly.new NoMethodError: private method `new' called for OneAndOnly:Class irb require 'singleton' class OneAndOnly include Singleton end http://www.ruby-doc.org/stdlib-2.1.1/libdoc/singleton/rdoc/Singleton.html
remember to do this * [3] [FIXME] remember to fix this * [4] [OPTIMIZE] remember to optimize this irb class ApplicationController < ActionController::Base # TODO: remember to do this # FIXME: remember to fix this # OPTIMIZE: remember to optimize this end Uppercase Only! cd railsapp; rake -T