Comment on if statement == false

<- View Parent
nickwitha_k@lemmy.sdf.org ⁨2⁩ ⁨weeks⁩ ago

If reading the code as non-programming logic, that conclusion makes sense, yes. However, if, in most syntaxes, is a type of flow control. What it wraps has no meaning to the if statement itself. Reading it through the lens of an interpreter/compiler makes it clear. The statement is approximately:

If and only if a is equal to 1, do the thing {
  The thing is: assign the variable b with the value 1
}

To one not familiar with how programs are executed, it would make sense that the return value could be 1. But understanding how flow control works in programming, makes this interpretation a challenge.

source
Sort:hotnewtop