On Thu, 2013-11-07 at 07:28 +0530, Sur wrote:
> e.g.
> 
> Ruby 1.9.3
> 
> 5.times{|i| if i == 0 then j = 1 end; print i, j,"\n"}
> 01
> 11
> 21
> 31
> 41
>  => 5
> 
> *Note that the block variables now is only |i|  and not |i; j|*

$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
stefan@AMD64X2 ~ $ irb
irb(main):001:0> 5.times{|i| if i == 0 then j = 1 end; print i, j,"\n"}
01
1
2
3
4
=> 5

I will get your result when j is declared prior outside of the
block/loop -- I was aware of that.

irb(main):003:0> j = nil; 5.times{|i| if i == 0 then j = 1 end; print i,
j,"\n"}
01
11
21
31
41
=> 5

I have to remember that .each and .times use blocks, so I have to
consider block scoping rules. But for, while and until loops do not need
blocks. Thanks, I think I understand this now.