--bWTBxx0QKOXH2iZ2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2006.10.28 00:20, Phrogz wrote:
> Eero Saynatkari wrote:
> > Is it possible to change NilClass#to_s to return "nil"
> > rather than "" since "" !=3D nil?
>=20
> 1) #to_s should always return a string.

Right.

> 2) Any string representation will always be a truth value.

Yep.

> The same situation exists for false:
> !!false.to_s  #=3D> true

true.to_s  # =3D> "true"
false.to_s # =3D> "false"
nil.to_s   # =3D> ""

"" is not a valid representation of nil. "nil" is.

> You are correct that "" !=3D nil, but "nil" !=3D nil also.
> What are you really trying to achieve? And, did you know that
> nil.inspect yields "nil"?

Yes. I want consistency.

--bWTBxx0QKOXH2iZ2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFQjN57Nh7RM4TrhIRAr8TAJ0UFae1AFHsxPJ4H9naDEt5iXXHpQCg67Lh
KSvdnW6VJyAJcLYvi9cw93M=
=WUWD
-----END PGP SIGNATURE-----

--bWTBxx0QKOXH2iZ2--

On 2006.10.28 00:20, Phrogz wrote:
> Eero Saynatkari wrote:
> > Is it possible to change NilClass#to_s to return "nil"
> > rather than "" since "" !=3D nil?
>=20
> 1) #to_s should always return a string.

Right.

> 2) Any string representation will always be a truth value.

Yep.

> The same situation exists for false:
> !!false.to_s  #=3D> true

true.to_s  # =3D> "true"
false.to_s # =3D> "false"
nil.to_s   # =3D> ""

"" is not a valid representation of nil. "nil" is.

> You are correct that "" !=3D nil, but "nil" !=3D nil also.
> What are you really trying to achieve? And, did you know that
> nil.inspect yields "nil"?

Yes. I want consistency.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFQjN57Nh7RM4TrhIRAr8TAJ0UFae1AFHsxPJ4H9naDEt5iXXHpQCg67Lh
KSvdnW6VJyAJcLYvi9cw93M=
=WUWD
-----END PGP SIGNATURE-----