Difference between "And" and "AndAlso" , "Or" and "OrElse"

Hi,
I just share a basic concept for the begginer to understand that the difference between And and AndAlso , Or and OrElse.

AndAlso - Operator

This is used to connect two (or more) logical conditions checking like if (condition1 AndAlso condition2).
If the first condition is false, It won’t perform the second condition .
So our execution time is saving in a logical operation in which more conditions are combined using “AndAlso" operator.

And - Operator

This is used to connect two (or more) logical conditions checking like if (condition1 And condition2).
It will perform both condition. Even first condition is false .
So our execution time is losing .


OrElse - Operator

This is used to connect two (or more) logical conditions checking like if (condition1 OrElse condition2).
If the first condition is true, It won’t perform the second condition.
So our execution time is saving in a logical operation in which more conditions are combined using “OrElse" operator.

Or - Operator

This is used to connect two (or more) logical conditions checking like if (condition1 Or condition2).
It will perform the both condition first and second. Even the first is true.
So our execution time is losing.

Here Is the sample : AndAlso.zip (21.2 KB)

Video Demo with example :

Thank you
Balamurugna.S

21 Likes

Thank you .

1 Like

hi @balupad14,

Thank you for sharing. The Tips you share are always Helpful.

One Ask : Do we have a consolidated page somewhere - Which can be accessed to get all the Tips you shared in past.


Mukesh

2 Likes

Hi @mukeshkala,

You can get all my videos in this channel. I will upload the past tips as video…

Thank you
Balamurugan.S

3 Likes

That would be awesome :slight_smile:

2 Likes

@balupad14, very helpful, thanks man.

1 Like

Great Tips! very very helpful

Thank you for the information. I have a question, what is the use of And, Or operators? As we learned from other languages I see AndAlso, OrElse seems useful but I am unable to get the reason for the other two operators when there is no use in evaluating the second condition when already confirmed the result.

And will be used if both the conditions should be Ok. and OR can be used if validation of either of the conditions should be Ok.

A=1
B=2

if(A=1 AND B=1). The result will be false
if(A=1 OR B=1). The result will be True

And and Or are used for bitwise operations.

E.g. 5 And 3 will give you 1

1 Like

Yes, that’s correct but my point was when we could able to conclude that the condition was already True (In OR) or False (In AND) by checking the 1st condition itself then what is the point in going to the 2nd condition.

No… There can be situations in your automations to check both conditions to true or either of the 2 conditions to be true.

There you can use AND / OR

Agreed. Sounds interesting!! I would realize when such a scenario comes up.

If you have such a scenario, I love to hear it and gain knowledge!!

Thanks for your time!!