New Operators

91 views
Skip to first unread message

Eugen

unread,
Dec 21, 2012, 3:22:10 AM12/21/12
to 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

unread,
Dec 21, 2012, 4:17:23 AM12/21/12
to 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
Reply all
Reply to author
Forward
0 new messages