Skip to content

Instantly share code, notes, and snippets.

@naohaq
Created July 19, 2012 04:44
Show Gist options
  • Save naohaq/3140812 to your computer and use it in GitHub Desktop.
Save naohaq/3140812 to your computer and use it in GitHub Desktop.
Use "if" as a name of a method.
#!/usr/bin/ruby1.9.1 -Ku
# -*- mode: ruby; coding: utf-8-unix -*-
class Foo
def if(p,t,f)
if p.call then
t.call
else
f.call
end
end
def hoge
self.if(lambda{ 1 != 2 },
lambda{ puts "True!" },
lambda{ puts "False!"})
end
end
Foo.new.hoge
# Local Variables:
# ruby-indent-level: 3
# indent-tabs-mode: nil
# End:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment