-1

Imagine the following piece of code:

if someBool && funcReturningABool() {
    // code here...
}

where someBool is a boolean and funcReturningABool returns true or false.

If someBool is equal to false, will the funcReturningABool still be executed?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
hacb
  • 175
  • 2
  • 10

2 Answers2

5

As you can find in the Golang documentation:

The right operand is evaluated conditionally

Titulum
  • 9,928
  • 11
  • 41
  • 79
4

it will not, and it is applicable not only to golang.

enter image description here

Serj1c
  • 140
  • 2
  • 7