Skip to content

Instantly share code, notes, and snippets.

@nakamuray
Created July 19, 2012 07:39
Show Gist options
  • Save nakamuray/3141393 to your computer and use it in GitHub Desktop.
Save nakamuray/3141393 to your computer and use it in GitHub Desktop.
if
def myif(b, then_block, else_block)
h = Hash.new(then_block)
h[false] = else_block
h[nil] = else_block
return h[b].call()
end
def mythen(&block)
return block
end
def myelse(&block)
return block
end
puts
puts "true"
puts "----"
myif true, mythen {
puts "hello world"
puts "hello world"
}, myelse {
puts "hello ruby"
}
puts
puts "false"
puts "-----"
myif false, mythen {
puts "hello world"
puts "hello world"
}, myelse {
puts "hello ruby"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment