From: David Vallner Date: 2006-12-17T04:11:36+09:00 Subject: Re: Just some Ruby language ideas, comments wanted. --------------enig3C14B38F3E15D4FFBB7E4009 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Devin Mullins wrote: >> This would allow things like: >> ary =3D [4, nil, 6, nil] >> ary.select{|x| x.nil?}[1].set(2) >> ary # =3D> [4, nil, 6, 2] > May I suggest: > ary.select{|x| x.nil?}[1] =3D 2 > as a better interface. >=20 This wouldn't work with the current semantics of select, since select returns a filtered copy of the array. I'm not sure I'd like if select returned some subclass of array that overrides []=3D to propagate changes back to the original one. First and foremost, potential massive code breakage without solving an actual use case. Secondly, it's emulating poor man's variable references that doesn't quite fit into Ruby. (Overall I don't see the use of this sort of collection view pattern much.) Maybe as part of Enumerator or Facets or a similar Library Of Somewhat Generic Spiffy Things, but not in the standard library, and definately not in a codebreaking way. David Vallner --------------enig3C14B38F3E15D4FFBB7E4009 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFhETiy6MhrS8astoRAsY6AJ9fx5ZvK2/bBI/ojS4HBlhqnbyLHgCeKwUE 4XFrgkLa2UlZmNfeCoKtdV8= =0lhn -----END PGP SIGNATURE----- --------------enig3C14B38F3E15D4FFBB7E4009--