From: "Shot (Piotr Szotkowski)" Date: 2009-11-19T23:35:38+09:00 Subject: Re: dynamic array? --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Freak Guard: > class DefaultArray < Array > attr_accessor :default_value > def initialize > super > @default_value =3D nil > end > def [](idx) > super || @default_value > end > end > ... and writing all the iterators I need You can always delegate them (or, as suggested, reopen Array or extend it). > which will be dead slow I assume :/ Don=E2=80=99t assume, benchmark it (it=E2=80=99s fairly trivial to do). You can see the following thread for inspiration =E2=80=93 and an example when a Hash-based custom set is (or at least seems to be) sometimes faster than the underlying Hash: http://groups.google.com/group/ruby-talk-google/browse_thread/thread/478a5d= dded16da09 =E2=80=94 Shot --=20 If you program and want any longevity to your work, make a game. All else recycles, but people rewrite architectures to keep games alive. [_why] --oyUTqETQ0mS9luUI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAksFV6YACgkQi/mCfdEo8UqE0wCgnN2OPoQ6OHvY0jpAY+YmlCMp uQUAn1vyhNuqBj3IIUwndCiVb+LkpWHM =DdZ/ -----END PGP SIGNATURE----- --oyUTqETQ0mS9luUI--