Trying to learn Groovy-- can I see the state of a different device?

Just trying to learn a little Groovy for my own amusement.

If I subscribe to 2 different switches. When the state of a switch changes it calls the handler I wrote to handle that event.

While in that handler will I be able to see the current status of the other switch even tho it might not have changed recently?

Put the word “current” before the attribute.
So for a switch device
def other_status = devicename.currentSwitch
should give you on or off in other_status

Another question. How do you do an AND or an OR function with in an IF. I was able to do it by nesting IF’s, but can’t seem to figure out how to do it within one IF. For example:

IF ( a==1 AND == 1). This gives me an error. (a and b are valid items, this is just an example.)

AND is &&
OR is ||

Assuming you want to test a for 1 and b for 1
if (a==1 && b==1)
{do something}

Assuming you want to test a for 1 or b for 1
if (a==1 || b==1)
{do something}

If you have not already looked at this, it may help
http://docs.smartthings.com/en/latest/getting-started/first-smartapp.html

I had been reading that but I couldn’t find the operators. Still can’t find them in the docs, but I’m sure they are there somewhere. Thanks for the help. That worked fine.