• 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: a simple Java question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a simple Java question


  • Subject: Re: a simple Java question
  • From: Ramsey Gurley <email@hidden>
  • Date: Tue, 4 Jan 2011 10:30:15 -0500

Interestingly, there's something called boolean algebra you can use to reduce an if statement to its simplest form. According to wikipedia, It was developed by George Boole, the father of boolean logic, back in the 1840s. I remember it from the early chapters of a free book, "The Art of Assembly", which I never finished reading.

http://en.wikipedia.org/wiki/Boolean_algebra_(logic)

Ramsey


On Jan 4, 2011, at 8:55 AM, Theodore Petrosky wrote:

duh!!!

as soon as I read the response I realized my error.

Thanks

Ted


--- On Tue, 1/4/11, Farrukh Ijaz <email@hidden> wrote:


From: Farrukh Ijaz <email@hidden>
Subject: Re: a simple Java question
To: "Theodore Petrosky" <email@hidden>
Cc: email@hidden
Date: Tuesday, January 4, 2011, 7:01 AM
Hi Ted,

You should use only estimates().

if(estimates()) {
    // your code.
}

jobIsClosed() || !jobIsClosed() will always return true as
at one given moment one of them will be true so anding it to
estimates() doesn't make sense as if estimates() is false
the evaluation will quit with false due to java precedence
which is left to right.

Farrukh

On 2011-01-04, at 2:51 PM, Theodore Petrosky wrote:



if (estimates() && jobIsClosed() ||
!jobIsClosed()) {}

I have these accessors (estimates()
jobIsClosed()). Do I need to parenthesize the second part of
this to be correct:

if (estimates() && (jobIsClosed() ||
!jobIsClosed())) {}


the first example is working as I intend, but I
originally had:

if (estimates() && jobIsClosed() ||
estimates() && !jobIsClosed()) {}


I was reading and searching on Java precedence and
couldn't find anything that specifically answered the
question. If I leave my code as the first example, will it
come back to bite me later? or is the second example more
correct?

Ted



_______________________________________________
Do not post admin requests to the list. They will be
ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden





_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: a simple Java question (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: been had jobs
  • Next by Date: <td style="$myStyle">foo</td>
  • Previous by thread: Re: a simple Java question
  • Next by thread: been had jobs
  • Index(es):
    • Date
    • Thread