Re: Odd or even numbers
Re: Odd or even numbers
- Subject: Re: Odd or even numbers
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 30 Nov 2006 23:13:46 -0500
Folks, folks! Stop it. Several people have proposed the same silly
solution here.
Code that looks like this:
if (anything) then set something to true
else set something to false.
It's the equivalent of doing this:
if x is 1 then set y to 1
else if x is 2 then set y to 2
else if x is 3 then set y to 3
etc., when what you really want is just this:
set y to x
In this case, you can just do this:
set myPage to (y mod 2 is 1)
Now, as Michelle points out, you can also take advantage of the fact
that if you cast a number to a boolean, the result is true if the
number is not zero. Because of that, her version also works:
set myPage to (y mod 2 as boolean)
Either way. The important thing is that there's no need to use an if
test of the goal is to assign the results of that test to a Boolean
variable.
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden