From: David Alan Black Date: 2002-01-19T20:45:17+09:00 Subject: Re: Hello! Array sub classing? Hi -- On Sat, 19 Jan 2002, Holden Glova wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Sat, 19 Jan 2002 16:52, Markt wrote: > > Holden Glova wrote: > > each line in the file, by default the delimeter is set to newline ($/). > > Once > > > > Yep, thanks. That helps. I think the next issue is when my code hits a > > 'nil' array element. > > > > Sooo.... what's a cute way of replacing 'nil' elements with say... " "? > > > > Regards! > > > > Markt > > Markt, perhaps you want to go through some sort of checking afterwards with > something like this? > > synack@eugene:~/downloads$ irb > irb(main):001:0> a = [1, 2, 3, nil, 4, 5] > [1, 2, 3, nil, 4, 5] > irb(main):002:0> a.find_all { |element| !element.nil? } > [1, 2, 3, 4, 5] Don't forget #compact :-) a = [1,2,3,nil,4,5] a.compact! a # => [1,2,3,4,5] David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav