From: Holden Glova Date: 2002-01-19T13:43:37+09:00 Subject: Re: Hello! Array sub classing? -----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] Array classes have Enumerable mixed into them so you get all the Enumerable functionality in the Array class, so you can say 'an Array is Enumerable' just like you can say 'an Array is an Object'. The find_all method is in Enumerable. Happy Ruby'ng - -- Signed, Holden Glova -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8SPot+mF116Lw2cQRAoXZAJ4mOHEdaXV5j2uxxhSWJWKe0nkJ6ACfaMiO B4RckcMZtpHKxOODmipvriw= =tC6/ -----END PGP SIGNATURE-----