[ create a new paste ] login | about

Link: http://codepad.org/eWXep5c8    [ raw code | output | fork ]

sah - Ruby, pasted on Jan 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Whiler
  def initialize(&cond)
    @cond = cond
  end

  def do
    while @cond.call
      yield
    end
  end
end

def _while(&cond)
  Whiler.new &cond
end

x = 0
_while{ x < 3 }.do{ x+=1; p x }


Output:
1
2
3
1
2
3


Create a new paste based on this one


Comments: