Zero is true ... whoda thunk?

You are just making the foolish mistake of assuming that just because my
@milk_volume attribute responds to #zero? its a number, which, of course, in
this mythical example, it isn’t. It’s a volume type (quart, in this case, as
I’m speaking to old-fashioned types…), quite well defined, so when Rover
checks if his milk volume, he finds out the answer in only ONE unit of
measurement…

David.

···

-----Original Message-----
From: Hal Fulton [mailto:hal9000@hypermetrics.com]

if got_milk? … end

where

def got_milk?
@milk_volume.zero?

Bugger. I mean !@milk_volume.zero? of course. So this whole
problem could
be avoided by making 0==false, thus proving your point. THIS
is why I don’t
post normally…

Haha… well, the got-milk logic would mean that negative numbers
would also be false, right? “I’ve got -5 gallons of milk. Give me
5 gallons, and I still won’t have any!”

Now you’ve got me thinking about the Mad Hatter’s tea party…

Well, we’re deving into semantics here, and I don’t want to start a
flamewar but I certainly have to concur that milk.volume == 0 is not
the same as milk == 0. In other words, because I don’t have any milk
doesn’t mean that the world has run out of milk. The milk in my fridge
is just an instance of the Milk class. Unlike the Matrix, we can’t say
that “there is no Milk”.
But let’s take another example for zero -let f(x) = x^2 - 4. Now, when
x is 2 then f(x) is zero. Does that mean that f(x) is false too? No.
Before anyone starts to cry foul let me state the following: zero has
instances where it is not false, as shown above. It also has instances
where it could be considered false (albeit with warnings). Compare
that to “false” and “nil”, which are false in every situation. The
latter are more consistent, don’t you think?
Cheers,
Claus

···

On Wed, 19 May 2004 12:53:56 +0900, David Naseby david.naseby@eonesolutions.com.au wrote:

-----Original Message-----
From: Hal Fulton [mailto:hal9000@hypermetrics.com]

if got_milk? … end

where

def got_milk?
@milk_volume.zero?

Bugger. I mean !@milk_volume.zero? of course. So this whole
problem could
be avoided by making 0==false, thus proving your point. THIS
is why I don’t
post normally…

Haha… well, the got-milk logic would mean that negative numbers
would also be false, right? “I’ve got -5 gallons of milk. Give me
5 gallons, and I still won’t have any!”

Now you’ve got me thinking about the Mad Hatter’s tea party…

You are just making the foolish mistake of assuming that just because my
@milk_volume attribute responds to #zero? its a number, which, of course, in
this mythical example, it isn’t. It’s a volume type (quart, in this case, as
I’m speaking to old-fashioned types…), quite well defined, so when Rover
checks if his milk volume, he finds out the answer in only ONE unit of
measurement…

David.

By far the best explanation IMHO.

claps
Archit

Claus Spitzer DocBoobenstein@gmail.com writes:

···

Well, we’re deving into semantics here, and I don’t want to start a
flamewar but I certainly have to concur that milk.volume == 0 is not
the same as milk == 0. In other words, because I don’t have any milk
doesn’t mean that the world has run out of milk. The milk in my fridge
is just an instance of the Milk class. Unlike the Matrix, we can’t say
that “there is no Milk”.
But let’s take another example for zero -let f(x) = x^2 - 4. Now, when
x is 2 then f(x) is zero. Does that mean that f(x) is false too? No.
Before anyone starts to cry foul let me state the following: zero has
instances where it is not false, as shown above. It also has instances
where it could be considered false (albeit with warnings). Compare
that to “false” and “nil”, which are false in every situation. The
latter are more consistent, don’t you think?
Cheers,
Claus

On Wed, 19 May 2004 12:53:56 +0900, David Naseby > david.naseby@eonesolutions.com.au wrote:

-----Original Message-----
From: Hal Fulton [mailto:hal9000@hypermetrics.com]

if got_milk? … end

where

def got_milk?
@milk_volume.zero?

Bugger. I mean !@milk_volume.zero? of course. So this whole
problem could
be avoided by making 0==false, thus proving your point. THIS
is why I don’t
post normally…

Haha… well, the got-milk logic would mean that negative numbers
would also be false, right? “I’ve got -5 gallons of milk. Give me
5 gallons, and I still won’t have any!”

Now you’ve got me thinking about the Mad Hatter’s tea party…

You are just making the foolish mistake of assuming that just because my
@milk_volume attribute responds to #zero? its a number, which, of course, in
this mythical example, it isn’t. It’s a volume type (quart, in this case, as
I’m speaking to old-fashioned types…), quite well defined, so when Rover
checks if his milk volume, he finds out the answer in only ONE unit of
measurement…

David.


Homepage: http://puggy.symonds.net/~bighead/
Projects:
http://peacock.sourceforge.net/
http://ore.rubyforge.net/