On 27 Jul 2001 03:39:12 +0900, Michael Witrant wrote:
> On Fri, 27 Jul 2001 02:52:05 +0900, "Bjorn Pettersen"
> <BPettersen / NAREX.com> wrote:
> 
> > Well, it's now two days into playing with Ruby, and I wrote my first
> > non-trivial program (it's converting a large c++ enum to constants).
> I'm
> > still shaky on idiomatic usage, so if any of the initiated would care
> to
> > comment on coding style I would be very grateful.
> > 
> > -- bjorn
> 
> I only have one comment in mind:
> 
> >             (0...row.length).each {|i|
> [...]
> >         (0... / maxcols.length).each {|n|
> 
> Here you can use the Fixnum#times method:
> 
>   row.length.times { |i|
>   @maxcols.length.times { |n|
> 
> It iterates from 0 to (self-1). But you might like (0...n) better.
Isn't there an each_index too??
: [bagfors / detrius]$ ; ruby -e 'a=[11,12,13,14]; a.each_index{|x| p
"#{x} = #{a[x]}"}'
"0 = 11"
"1 = 12"
"2 = 13"
"3 = 14"


Yes there is


--
Erik B?gfors               | http://erik.bagfors.nu/    
erik / bagfors.nu            | Erik.Bagfors / ardendo.se
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32

--
Erik B?gfors               | http://erik.bagfors.nu/    
erik / bagfors.nu            | Erik.Bagfors / ardendo.se
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32
-- 
Erik B?gfors               | erik / bagfors.nu
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32