# define our apple Proc apple = proc { |t| puts "my apple" + t } # doIt1 with if statements def doIt1(c, t) if t.respond_to?("call") puts "-- callable" c.call " is awesome" t.call " is really awesome" elsif t.kind_of?(Array) puts "-- not callable Array" t.each { |t1| c.call t1 } else puts "-- not callable String" c.call t end end # doIt2 with case/switch block def doIt2(c, t) case t when Proc puts "-- callable" c.call " is awesome" t.call " is really awesome" when Array puts "-- not callable Array" t.each { |t1| c.call t1 } when String puts "-- not callable String" c.call t else puts "not valid" end end # doIt1 tests doIt1 apple, apple doIt1 apple, " works good" doIt1 apple, " works hard" doIt1 apple, [" looks good", " looks elagant", " looks shiny"] # *'s used to separate method tests puts "*" * 40 puts "*" * 40 # doIt2 tests doIt2 apple, apple doIt2 apple, " works good" doIt2 apple, " works hard" doIt2 apple, [" looks good", " looks elagant", " looks shiny"]