The explanation says: "Observe that (rightTurn && !pedestrian || otherLane) is true, therefore ( ? && !pedestrian && greenLight ) does not matter."
Since the part of "rightTurn && !pedestrian" is true does the short circuit operator || even consider otherLane?
Would the correct explanation then be:
Observe that "rightTurn && !pedestrian" is true, therefore "|| otherLane)" and "( ? && !pedestrian && greenLight )" does not matter?
About Question enthuware.ocajp.i.v7.2.929 :
Moderator: admin
-
- Posts: 5
- Joined: Fri Jul 15, 2016 8:55 am
- Contact:
-
- Site Admin
- Posts: 10056
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.929 :
No, the given explanation is correct. The expression in the question has two parts separated by ||, which is a short circuit operation. The explanation is telling you that the first part i.e. (rightTurn && !pedestrian || otherLane) evaluates to true that is why the second part i.e. ( ? && !pedestrian && greenLight ) is not considered.
Now, the first part of the main expression itself contains a short circuit operator and since the first subpart of that expression is true, the second subpart will not be considered. This is also true. But this is irrelevant from the perspective of the overall expression. As far as the complete expression is concerned, the first part i.e. (rightTurn && !pedestrian || otherLane) is evaluated and the second part is not.
HTH,
Paul.
Now, the first part of the main expression itself contains a short circuit operator and since the first subpart of that expression is true, the second subpart will not be considered. This is also true. But this is irrelevant from the perspective of the overall expression. As far as the complete expression is concerned, the first part i.e. (rightTurn && !pedestrian || otherLane) is evaluated and the second part is not.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 46 guests