• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Odd or even numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Re: Odd or even numbers (From: The Server Surfer <email@hidden>)

  • Prev by Date: Re: (no subject)
  • Previous by thread: Re: Odd or even numbers
  • Index(es):
    • Date
    • Thread