Both are equivalent. From the Xtext docs:
When a method call’s last parameter is a lambda it can be passed right after the parameter list. For instance if you want to sort some strings by their length, you could write :
Collections.sort(someStrings) [ a, b |
a.length - b.length
]
which is just the same as writing
Collections.sort(someStrings, [ a, b |
a.length - b.length
])
Since you can leave out empty parentheses for methods which get a lambda as their only argument, you can reduce the code above further down to:
textField.addActionListener [
textField.text = “Something happened!”
]
Personally I think it is a really bad design choice. If a lambda can/should be treated like any other object than don’t give it special syntax and abilities when it is an argument to a method call. I therefore always use the latter form.
Now if I were using Xtext for general purpose programming and had to create a bunch of action listeners like in that example I might have a different opinion of this. But for the Rules DSL I think it only adds confusion.