-2

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?

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875

1 Answers1

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