Answer the question
In order to leave comments, you need to log in
How is such a construction implemented in programming languages?
1. A || B
2. A && B
In the first case, it will be true if one of the two is true. In the second case, it will be true if both are true at the same time. With this, everything is clear, the school program.
Imagine that A and B are, for example, function calls that mutate somewhere, change something, etc. In the first case, function B will be executed only if function A returns false after its execution. Accordingly, in the second case, B will be executed if A returns true. This statement is true for javascript.
Now the actual question. Is this statement true for other languages? Is this behavior dependent on the PL or is it something fundamental and will work the same in any PL?
Answer the question
In order to leave comments, you need to log in
What you are talking about is only true for dynamically typed languages like javascript. There you can do something like this
var predicate = true;
var anyMethod = function() { ... }
if(predicate && anyMethod){ ... }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question