Skip to content

Instantly share code, notes, and snippets.

@gtkatakura
Created July 28, 2016 02:34
Show Gist options
  • Save gtkatakura/cc740e395009804e8be2fb2e471f11c5 to your computer and use it in GitHub Desktop.
Save gtkatakura/cc740e395009804e8be2fb2e471f11c5 to your computer and use it in GitHub Desktop.
EndNo = Class.new {
define_method(:if_example) { |condition|
(condition && ->{
"yeah, true!"
} || ->{
"why not?"
}).call
}
define_method(:while_example) { |limit|
(whiler = ->{
limit > 0 && ->{
limit -= 1
puts limit
whiler.call
}.call
}).call
}
define_method(:for_example) { |limit|
limit.times { |i| puts i }
}
}
EndNo.new.if_example(true)
EndNo.new.if_example(false)
EndNo.new.while_example(5)
EndNo.new.for_example(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment