This is a MIME message. If you are reading this text, you may want to 
consider changing to a mail reader or gateway that understands how to 
properly handle MIME multipart messages.

--
A82CD59.F998FC3A
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

In terms of documenting code,

(n % 2 == 1)

is *much* less satisfactory than

(n.even?)

And in any case, sometimes the first equation could mean different things (even though the result is identical).  For instance:

(n.valve_open?)

could have the same meaning if the last bit is being tested for being one or zero.  If you use the first equation, none of this can be seen in the code.

However, matz's point comes into its own here: why not use

def even?
   n % 2 == 1
end

??  The only thing gained otherwise would be machine optimization.

David Douthitt
UNIX Systems Administrator
ddouthitt / cuna.com
(608) 231-4922


>>> matz / netlab.co.jp 5/17/00 9:11p >>>
The following message is a courtesy copy of an article
that has been posted to comp.lang.ruby as well.

Hi,

Finally, I got access to comp.lang.ruby.

Dave Thomas <Dave / Thomases.com> writes:

|Does anyone else think that Integer#odd? would be useful?

Both

  n % 2 == 1
  (n ^ 1) == 1

would work.  Do we really need it?
If I have to add odd?, I'd add even? too.

                            matz.

--
A82CD59.F998FC3A
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY style="FONT: 8pt MS Sans Serif; MARGIN-LEFT: 2px; MARGIN-TOP: 2px">
<DIV><FONT size=1>In terms of documenting code,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>(n % 2 == 1)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>is *much* less satisfactory than</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>(n.even?)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>And in any case, sometimes the first equation could mean 
different things (even though the result is identical).&nbsp; For 
instance:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>(n.valve_open?)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>could have the same meaning if the last bit is being tested 
for being one or zero.&nbsp; If you use the first equation, none of this can be 
seen in the code.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>However, matz's point comes into its own here: why not 
use</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>def even?</FONT></DIV>
<DIV><FONT size=1>&nbsp;&nbsp; n % 2 == 1</FONT></DIV>
<DIV><FONT size=1>end</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>??&nbsp; The only thing gained otherwise would be machine 
optimization.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=1>David Douthitt<BR>UNIX Systems Administrator<BR><A 
href="mailto:ddouthitt / cuna.com">ddouthitt / cuna.com</A><BR>(608) 
231-4922<BR></FONT></DIV>
<DIV><BR>&gt;&gt;&gt; matz / netlab.co.jp 5/17/00 9:11p &gt;&gt;&gt;<BR>The 
following message is a courtesy copy of an article<BR>that has been posted to 
comp.lang.ruby as well.<BR><BR>Hi,<BR><BR>Finally, I got access to 
comp.lang.ruby.<BR><BR>Dave Thomas &lt;Dave / Thomases.com&gt; 
writes:<BR><BR>|Does anyone else think that Integer#odd? would be 
useful?<BR><BR>Both<BR><BR>&nbsp; n % 2 == 1<BR>&nbsp; (n ^ 1) == 1<BR><BR>would 
work.&nbsp; Do we really need it?<BR>If I have to add odd?, I'd add even? 
too.<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
matz.<BR></DIV></BODY></HTML>

--
A82CD59.F998FC3A--