From: Aaron Patterson Date: 2012-03-03T01:41:37+09:00 Subject: [ruby-core:43055] Re: return values of methods on String subclasses --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 02, 2012 at 10:58:43PM +0900, Nobuyoshi Nakada wrote: > Hi, >=20 > (12/03/02 13:38), Aaron Patterson wrote: > >> Seems that patch would break other subclasses of String, whose > >> initialize_copy doesn't expect whole original string. > >=20 > > When would this happen? >=20 > With your patch: >=20 > $ ./ruby -e 'class S < String; end; p S.new("abcdef")[0, 2]' > "abcdef" Ah right. I suppose we could check if the subclass actually has `initialize_copy` in it's method table. But I think if the subclass calls `super` it would still break. :( Maybe we do need a new hook method. --=20 Aaron Patterson http://tenderlovemaking.com/ --GvXjxJ+pjyke8COw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJPUPg8AAoJEJUxcLy0/6/GFDsIAIJIolUXO3JGbAg3pm3W0Iyz NO3sXmyqDyrSBMp6SxnSrPDP40ezWt5PmqhhInXcucLarFVEBN5hfIW3hW/XcBc7 qQDt0kk7tUhYZrib8oLIBYMqZ49Z7rDWQMBJvUDGMdNwsb7Ta++3L9W/Ibt6L8tY 40BCIudZ/CDG/ek1cPoEf0/Z0qIK3qpf8EsOOFsQbWoPCedDePkLo9f4aYgrC88k HL59s63CbP2eUsaDvcLWbwgqv8Seet0kjJe+4CFt0LVNVzyq6iWBggYyUIrklhuu 3vWAeNFDJy41BcCqoZmVEf/uXDe+yrBOZRaSjoOnpSzGMKo3Cywd2A5j09d+sow= =V290 -----END PGP SIGNATURE----- --GvXjxJ+pjyke8COw--