Code Comments
Programming Forum and web based access to our favorite programming groups.
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
Post Follow-up to this messageAki "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
Post Follow-up to this messageChristophe Vanfleteren <c.v4nfl3t3r3n@pandora.be> writes: > boolean sequenceContinues = ([condition]); No, that doesn't do the same thing.
Post Follow-up to this messageChristophe 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."
Post Follow-up to this messageOn 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.
Post Follow-up to this messageAki "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
Post Follow-up to this message
> 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;
}
}
}
Post Follow-up to this messageJean-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
Post Follow-up to this message"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;
Post Follow-up to this messageOn 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.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.