A
Andreas S
Hopefully (I'm sure) somebody can shed a light on this. This caught me by s=
urprise
test.rb:
TEST =3D []
def procs &block
TEST << block
end
#for n in [1,2,3] do
[1,2,3].each do |n|
procs do
puts "#{n}"
end
end
TEST.each do |t|
puts t
t.call
end
With for loop#
3
#
3
#
3
With each#
1
#
2
#
3
I thought for-loop behaves the same as each. Apparently not. Why is this an=
d is this a good thing?
Thank you in advance
-andre
_________________________________________________________________
Climb to the top of the charts!=A0 Play Star Shuffle:=A0 the word scramble =
challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=3Dstarshuffle_wlmailtextlink_oc=
t=
urprise
test.rb:
TEST =3D []
def procs &block
TEST << block
end
#for n in [1,2,3] do
[1,2,3].each do |n|
procs do
puts "#{n}"
end
end
TEST.each do |t|
puts t
t.call
end
With for loop#
3
#
3
#
3
With each#
1
#
2
#
3
I thought for-loop behaves the same as each. Apparently not. Why is this an=
d is this a good thing?
Thank you in advance
-andre
_________________________________________________________________
Climb to the top of the charts!=A0 Play Star Shuffle:=A0 the word scramble =
challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=3Dstarshuffle_wlmailtextlink_oc=
t=