This is how you do recursion, but using these instance variables is not the way to go. A better example might be the following:
def b_stage(i) if i < 5 puts i i += 1 b_stage(i) end end
If you call b_stage(0) , the output will be
0 1 2 3 4
source share