Skip to main content
Participating Frequently
February 21, 2009
Question

java or operator statement and expressions

  • February 21, 2009
  • 2 replies
  • 4584 views
So I tried to simplify some code this morning using the java or operator and it doesn't seem to work. It went something like this:
if ((time < 4) || (time > 10))}
val = aVariable}
else val=0;
What I end up with is zero until 4 but after 10 the val does not return to 0.

I hope this makes sense to somebody out there. I just went back to a stack of if else statements to solve the problem.

Thanks
This topic has been closed for replies.

2 replies

Participating Frequently
February 21, 2009
Thanks Dan. That was it.

When I'm coding at 3AM i tend to make silly type-os... and omissions!

Rick
Dan Ebberts
Community Expert
Community Expert
February 21, 2009
I'm not sure what the problem is (except that your curly brackets are wrong), but this opacity expression works:

if ((time < 4) || (time > 10)){
0
}else{
100
}

Dan