From: Peter Zotov Date: 2012-06-07T11:21:05+09:00 Subject: Re: "Create a rock paper scissors program in ruby WITHOUT using conditionals" Ryan Davis писал 07.06.2012 05:24: > On Jun 6, 2012, at 15:54 , Peter Zotov wrote: > >> Instead of this: >> >> if arg == "a" >> 1 >> elsif arg == "b" >> 2 >> end >> >> ... you can use: >> >> { "a" => 1, "b" => 2 }[arg] >> >> I leave the rest to your imagination. > > I think this is too limiting / not mind-expanding enough... > > I suggest looking at how smalltalk does branching (conditionals, > loops, etc). Oh, what an amazing idea. def true.ex(a, b) a.() end def false.ex(a, b) b.() end (arg == "a").ex(-> { puts "arg is a" }, -> { puts "arg isn't a" }) I leave the task of explaining this (and its origins) to your professor to yourself. Also, google for "church numerals" and "lambda calculus"--you won't be disappointed! :D -- WBR, Peter Zotov.