codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
class NoOp def self.elif(cond) NoOp end def self.else NoOp end end class Ifer def initialize(cond) @cond = cond end def then if @cond yield NoOp else self end end def elif(cond) if cond yield NoOp else self end end def else if !@cond yield NoOp else self end end end def _if(cond) Ifer.new cond end x = 4 _if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" } x = 1 _if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" } x = 0 _if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" }
Private
[
?
]
Run code