pls differentiate logical and & logical short circuit and | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

pls differentiate logical and & logical short circuit and

23rd Jul 2016, 7:28 AM
sreeraj g
sreeraj g - avatar
4 Answers
+ 2
the first & operator is a logical boolean operator that returns true if both inputs to the operator are true, whilst, there logical short circuit && terminates (short circuits) on a conditional statement where one of the boolean inputs is false and doesn't bother to evaluate the other input. the first & is primarily used in binary operations like in 0b0001 & 0b1000 = 0b0001
23rd Jul 2016, 4:18 PM
Eric Gitangu
Eric Gitangu - avatar
+ 1
so logical and will evaluate both operands and logical short circuit and wont?
23rd Jul 2016, 4:24 PM
sreeraj g
sreeraj g - avatar
0
Yes.
23rd Jul 2016, 4:25 PM
Eric Gitangu
Eric Gitangu - avatar
0
thanx eric👍
23rd Jul 2016, 4:27 PM
sreeraj g
sreeraj g - avatar