From: Chad Perrin Date: 2011-05-29T09:51:01+09:00 Subject: Re: Method that mutates object --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 29, 2011 at 09:29:41AM +0900, Gary Wright wrote: >=20 > My main point was that 'immutable' is the wrong term to apply to > fixnum objects (and all other objects) in Ruby. You can add instance > variables to anything. I must be doing something wrong, then: irb(main):001:0> module Mod irb(main):002:1> end =3D> nil irb(main):003:0> bar =3D 'bar' =3D> "bar" irb(main):004:0> bar.extend Mod =3D> "bar" irb(main):005:0> foo =3D 1 =3D> 1 irb(main):006:0> foo.extend Mod TypeError: can't define singleton from (irb):6:in `extend_object' from (irb):6:in `extend' from (irb):6 from /usr/bin/irb1.9.1:12:in `
' =2E . . and I haven't even tried adding an instance variable to that module yet. How should I add an instance variable to my fixnum object if not with extend? --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --9amGYk9869ThD9tj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk3hlRQACgkQ9mn/Pj01uKWfbACfdL85wNw9sCBHHZkhZiF1hV+t q44AoNhy9hMbBmJl8RvskYCBzp20HNR8 =nhBk -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--