Created
          July 28, 2016 02:34 
        
      - 
      
- 
        Save gtkatakura/cc740e395009804e8be2fb2e471f11c5 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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