You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected output? What do you see instead?
I expected the entire expression after the + operator to be evaluated before being bound to the operator itself. The operator is binding strongly to the 'foo' Object, rather than the expression result.
The following works however, because of the explicit binding defined by the parenthesis:
var s = 'hello' + (foo != null ? " world." : "");
What version of the product are you using? On what operating system?
Version 0.1.0.201111090748
Dart Editor: build 1357
Please provide any additional information below.
The text was updated successfully, but these errors were encountered:
The precedence of the operators (binding strength) is decided by the parser, so addition of two numbers and concatenation of two strings must have the same binding strength. In general, it is impossible to know what the types of the inputs to a "+" operation are statically - they must be tested dynamically at runtime.
Because the order of operations is based on that of C-family and Java-family languages, and people really want to be able to write tests like
sum == subtotal_a + subtotal_b, et. cetera, it is impossible
to make + bind less tightly than comparisons. The conditional operator (a ? b : c)
binds even less tightly, so your expectation about the binding of + is very different
from the expectations of most programmers.
You're right, I checked the expression binding in C# and it works the
same.. I'll make a note not to submit "bugs" after marathon coding
sessions anymore.
This issue was originally filed by [email protected]
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expected the entire expression after the + operator to be evaluated before being bound to the operator itself. The operator is binding strongly to the 'foo' Object, rather than the expression result.
The following works however, because of the explicit binding defined by the parenthesis:
var s = 'hello' + (foo != null ? " world." : "");
What version of the product are you using? On what operating system?
Version 0.1.0.201111090748
Dart Editor: build 1357
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: