• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

if statement woes

I can't wrap my head around how to write the following if statement. Some help would be greatly appriciated

"if a counter variable has decremented by one then allow"

Code:
cou0--
if(cou0 ???){
  //cou0 has changed
}

Seems to me that the only really reasonable way to do that would be to set a temp var before whatever code decrements it:
Code:
ctemp = cou0
// whatever code determines the decrement
cou0--
if (cou0 == ctemp-1) {
  // cou0 has changed
}

I don't see any other approach that would be viable.
 
Upvote 0
Seems to me that the only really reasonable way to do that would be to set a temp var before whatever code decrements it:
Code:
ctemp = cou0
// whatever code determines the decrement
cou0--
if (cou0 == ctemp-1) {
  // cou0 has changed
}

I don't see any other approach that would be viable.
Perfect Thanks!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones