I have a doubt of how this if loop is going to work. if fn1 evaluates to be true, will it still go for checking fn2 or will it go into the if loop and add the elements into the list?
Asked
Active
Viewed 69 times
-2
-
2What language is this? – Cody Gray - on strike Feb 28 '16 at 14:52
-
Please search before posting, use appropriate tags, and ensure that your question really reflects the code you're askign about. – T.J. Crowder Feb 28 '16 at 15:26
1 Answers
0
The ||
operator is short-circuited, meaning that if the left-hand operand is true (whatever that means in the language in question), the right-hand operator isn't evaluated at all. So in your example, fn1
will definitely be called, but fn2
will only be called if fn1
returns false
.

T.J. Crowder
- 1,031,962
- 187
- 1,923
- 1,875
-
Yeah, I meant a function call with arguments(Edited my question). Thanks for answering – Harsha Nooka Feb 28 '16 at 15:02