Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make AND or OR expressions?

I wrote this:

if( a == -11 && b == -1 ){
{

if( a == -1) AND ( b == -1)...

But neither work, and I have the same problem with OR. How do I write expressions that include OR or AND?

like image 621
user761812 Avatar asked May 25 '11 00:05

user761812


People also ask

Why can't I make calls with my Apple Watch?

If your phone is in Airplane mode, you won't be able to make calls from your watch. Try disconnecting Bluetooth on your phone so the watch doesn't know your phone is in Airplane mode.

Can I use my Mac to make phone calls?

Make calls from apps on your MacIn the FaceTime app on your Mac, sign in and make sure FaceTime is turned on. Set up your iPhone and Mac for phone calls, if you haven't done so already. to choose the phone number to call.

How do I configure my iPhone to make calls from my Mac?

On your iPhone, go to Settings > Phone > Calls on Other Devices, then turn on Allow Calls on Other Devices. On your iPad or iPod touch, go to Settings > FaceTime, then turn on Calls from iPhone. On your Mac, open the FaceTime app, then choose FaceTime > Preferences. Click Settings, then select Calls From iPhone.


3 Answers

You use && for “and”, and || for “or”.

like image 126
edc1591 Avatar answered Sep 22 '22 02:09

edc1591


(a == -11 && b == -1) is fine and correct. Objective-C uses all of the same logical operators as C. || is the logical-or operator.

like image 34
Seamus Campbell Avatar answered Sep 22 '22 02:09

Seamus Campbell


if (a==-11 && b==-1) {

if perfectly legal in C, and therefore Objective-C.

Your second example is not C or Objective-C

like image 43
Yann Ramin Avatar answered Sep 23 '22 02:09

Yann Ramin