New Operators

91 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Eugen

nieprzeczytany,
21 gru 2012, 03:22:1021.12.2012
do xtend...@googlegroups.com
Hey,

i've been using Xtend for some weeks now, and it is really great with work with, since I'm more a C#-Guy this Xtend is awesome for Android Programming and other simple tools (to learn).

Anyway I'm missing some operators:

Code:
(Syntax: Operator | Explanation)
a -= b | a = a - b
a *= b | a = a * b
a /= b | a = a * b

a == true ? 10 : 30 | Instead of if(a == true) 10 else 30

Best regards,
Eugen

Sven Efftinge

nieprzeczytany,
21 gru 2012, 04:17:2321.12.2012
do xtend...@googlegroups.com
On Dec 21, 2012, at 9:22 AM, Eugen <eugen...@googlemail.com> wrote:

Hey,

i've been using Xtend for some weeks now, and it is really great with work with, since I'm more a C#-Guy this Xtend is awesome for Android Programming and other simple tools (to learn).

Anyway I'm missing some operators:

Code:
(Syntax: Operator | Explanation)
a -= b | a = a - b
a *= b | a = a * b
a /= b | a = a * b

we have already overloaded '+=' to map to left.operator_add(right). But there's no reassignment involved, which would be a bit error prone, in combination with operator overloading.
I can imagine adding the operators like this :

a -= b | a.operator_minusEquals(b)
a *= b | a.operator_starEquals(b)
a /= b | a.operator_slashEquals(b)

But then they wouldn't do what you are looking for.
Maybe we could annotate the operator-method with something that indicates that the result should be assigned to the feature call on the left.
Please file a bugzilla to track further discussion.


a == true ? 10 : 30 | Instead of if(a == true) 10 else 30

I don't think it's worth it.
What are the advantages of the ternary operator over an if expression?

Sven
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0