function call operator? [message #1751227] |
Thu, 05 January 2017 15:23  |
Eclipse User |
|
|
|
Today I scoured the XTend source code looking for an operator that would do something as simple as taking an input argument, binds it to the scope of a lambda expression and returns the output of the lambda. Maybe I searched wrong but I could not find anything like that.
In the end I implemented it as a method:
def <T, R> R call(T input, Function1<T, R> lambda) {
lambda.apply(input)
}
And it can be used like this:
1.call[i|i+1].call[j|j-1].assertEquals(1)
I just thought it could be useful to have an operator for this.
Questions:
1) Can I use custom operators in XTend?
2) Could we add this operation to the ObjectExtensions class?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03067 seconds