Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Negation of boolean
Hi again :)

One of those "Can yuo do this?" -type questions again:
Anything wrong with:

boolean sequenceContinues = false;
if([condition]){
sequenceContinues = !sequenceContinues;
}
else{}

?

--
-Aki "Sus" Laukkanen



Report this thread to moderator Post Follow-up to this message
Old Post
Aki \Sus\ Laukkanen
07-29-04 02:09 AM


Re: Negation of boolean
Aki "Sus" Laukkanen wrote:

>
> Hi again :)
>
> One of those "Can yuo do this?" -type questions again:
> Anything wrong with:
>
> boolean sequenceContinues = false;
> if([condition]){
> sequenceContinues = !sequenceContinues;
> }
> else{}
>
> ?

Rewrite that as

boolean sequenceContinues = ([condition]);

--
Kind regards,
Christophe Vanfleteren

Report this thread to moderator Post Follow-up to this message
Old Post
Christophe Vanfleteren
07-29-04 02:09 AM


Re: Negation of boolean
Christophe Vanfleteren <c.v4nfl3t3r3n@pandora.be> writes:

> boolean sequenceContinues = ([condition]);

No, that doesn't do the same thing.

Report this thread to moderator Post Follow-up to this message
Old Post
Tor Iver Wilhelmsen
07-29-04 02:09 AM


Re: Negation of boolean
Christophe Vanfleteren wrote:

> Aki "Sus" Laukkanen wrote:
>
> 
>
>
> Rewrite that as
>
> boolean sequenceContinues = ([condition]);

That wouldn't accomplish what I'm trying to do. sequenceContinues is
supposed to change from flase to true or vice versa...
I actually mis-quoted my code, the if-block should be inside a while-loop.
Sorry about the confusion.

--
-Aki "Sus" Laukkanen
"No Akia nyt on niin helppo raadella - senkun vaan raatelee."


Report this thread to moderator Post Follow-up to this message
Old Post
Aki \Sus\ Laukkanen
07-29-04 02:09 AM


Re: Negation of boolean
On Wed, 28 Jul 2004 18:35:56 +0300, "Aki \"Sus\" Laukkanen"
<aki.laukkanenREMOVETHIS@helsinki.fi> wrote or quoted :

>One of those "Can yuo do this?" -type questions again:
>Anything wrong with:
>
>boolean sequenceContinues = false;
>if([condition]){
>	sequenceContinues = !sequenceContinues;
>}
>else{}

Would it not be simpler to write:

boolean sequenceContinues = conditionexpression;

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Report this thread to moderator Post Follow-up to this message
Old Post
Roedy Green
07-29-04 02:09 AM


Re: Negation of boolean
Aki "Sus" Laukkanen wrote:
>
> Hi again :)
>
> One of those "Can yuo do this?" -type questions again:
> Anything wrong with:
>
> boolean sequenceContinues = false;
> if([condition]){
>     sequenceContinues = !sequenceContinues;
> }
> else{}
>
> ?

Nothing objectionable that I can see.  You could optimiize
(or obfuscate) the inversion a little:

sequenceContinues ^= true;

--
Eric.Sosman@sun.com


Report this thread to moderator Post Follow-up to this message
Old Post
Eric Sosman
07-29-04 02:09 AM


Re: Negation of boolean

> That wouldn't accomplish what I'm trying to do. sequenceContinues is
> supposed to change from flase to true or vice versa...
> I actually mis-quoted my code, the if-block should be inside a while-loop.
> Sorry about the confusion.
>
> --
> -Aki "Sus" Laukkanen
> "No Akia nyt on niin helppo raadella - senkun vaan raatelee."
>

You just want a loop that change the value of a boolean ??? Here is a simple
class with a main method which print the doSequence value and switch it 10
times.

public class SwitchVal {

public static void main(String[] args) {

boolean doSequence = false;

for (int i=0; i<10; i++){

System.out.println(doSequence);

doSequence = !doSequence;

}

}

}



Report this thread to moderator Post Follow-up to this message
Old Post
Jean-Philippe Martin
07-29-04 02:09 AM


Re: Negation of boolean
Jean-Philippe Martin wrote:


> You just want a loop that change the value of a boolean ??? Here is a simp
le
> class with a main method which print the doSequence value and switch it 10
> times.

Actually, I want it to change the value only if the "if" condition is
met (and do some other stuff as well, regardless of whether it changed
the value or not.) (That other stuff varies depending on the value of
the boolean.)

--
-Aki "Sus" Laukkanen


Report this thread to moderator Post Follow-up to this message
Old Post
Aki \Sus\ Laukkanen
07-29-04 02:09 AM


Re: Negation of boolean
"Aki "Sus" Laukkanen" <aki.laukkanenREMOVETHIS@helsinki.fi> a écrit dans le
message de news:ce8h4s$f6v$1@oravannahka.helsinki.fi...
>
> Hi again :)
>
> One of those "Can yuo do this?" -type questions again:
> Anything wrong with:
>
> boolean sequenceContinues = false;
> if([condition]){
> sequenceContinues = !sequenceContinues;
> }
> else{}
>
> ?
>
> --
> -Aki "Sus" Laukkanen
>
>

It appears that I've misunderstood the question... Can it be more clear?
Maybe may I help;



Report this thread to moderator Post Follow-up to this message
Old Post
Jean-Philippe Martin
07-29-04 02:09 AM


Re: Negation of boolean
On Wed, 28 Jul 2004 23:22:17 +0200, Patrick <tuin01@home.nl> wrote or
quoted :

>sequenceContinues= condition ? !sequenceContinues:sequencecontinues;

How many of you know what this code does without looking it up?

sequenceContinues ^= condition;
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Report this thread to moderator Post Follow-up to this message
Old Post
Roedy Green
07-29-04 02:09 AM


Sponsored Links




Last Thread Next Thread Next
Pages (4): [1] 2 3 4 »
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.