M
Mike Glaz
here's the example:
1. def fib_up_to(max)
2. i1,i2 = 1,1
3. while i1 <= max
4. yield i1
5. i1, i2=i2, i1+i2
6. end
7. end
8.
9. fib_up_to(1000) {|f| print f, " "}
I'm familiar with yield passing values to the block and vice-versa. But
I have no clue what is happenening in line 5. Or at least in general
can anyone explain what is going on here in these 9 lines of code?
(I've been programming for 10 years so I'm familiar methods, loops, etc.
it's just this yield thing I don't completely understand especially line
5.).
cheers,
mike
1. def fib_up_to(max)
2. i1,i2 = 1,1
3. while i1 <= max
4. yield i1
5. i1, i2=i2, i1+i2
6. end
7. end
8.
9. fib_up_to(1000) {|f| print f, " "}
I'm familiar with yield passing values to the block and vice-versa. But
I have no clue what is happenening in line 5. Or at least in general
can anyone explain what is going on here in these 9 lines of code?
(I've been programming for 10 years so I'm familiar methods, loops, etc.
it's just this yield thing I don't completely understand especially line
5.).
cheers,
mike