• Post Reply Bookmark Topic Watch Topic
  • New Topic

if's  RSS feed

 
George Willis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why somehow during my 4th If statement that my Boolean 'up' gets changed to False. I don't understand if 'up' is now changed to False that 'i' does not decrement. I figure that if the If does not satisfy the condition it should simply be skipped. But that does not seem to be the case.


CONSOLE RESULTS:
Value of i = 0
Value of up-1 = true
Value of up-2 = true
Value of up-3 = true
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 1
Value of up-1 = false
Value of up-2 = false
Value of up-3 = false
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 2
Value of up-1 = false
Value of up-2 = false
Value of up-3 = false
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 3
...etcetera....

Thanks

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is something that is tricky for those new to Java


This assigns true to up and checks if up is true. Which it always is.


This checks if up is true.

You want the second one.
 
George Willis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grrrr! I knew that but noobed it nonetheless.
Thanks!
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
What do you mean by 'noobed'?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's one reason why I think it's preferable to use if(up) and if(!up), instead of if(up == true) and if(up == false).
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never try writing == false or == true.
Always write if (up)... or if (!up)...
That should prevent that particular error.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Ngom wrote:Hi George,
What do you mean by 'noobed'?

noob is slang for someone new to something. It is a synonym for newbie.

Noobed is not something I had heard before, but I can infer it to mean to make a mistake that a new person would make.
 
Scott Winterbourne
Ranch Hand
Posts: 116
2
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Never try writing == false or == true.
Always write if (up)... or if (!up)...
That should prevent that particular error.


This is something I need to keep in mind for myself also. I tend to write == true or == false.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

noob is slang for someone new to something. It is a synonym for newbie.

Noobed is not something I had heard before, but I can infer it to mean to make a mistake that a new person would make.

Thank you Jeanne. I now get the meaning.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which case it would be best to avoid noob as a verb in future, please. One reason for requiring real words is that they cause confusion to non‑native English speakers.
 
George Willis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the rules mistake.
And, thank you all for the further discussion and advice.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!