How to assign the return value of a CIS
Peter Levart
peter.levart at marand.si
Fri Jan 8 04:55:51 PST 2010
On Friday 08 January 2010 13:13:45 Gernot Neppert wrote:
> Hello,
>
> I'm wondering about how to assign the return value of a
> ControlInvocationStatement to a variable.
> Or can the return value of a CIS never be used if the special syntax
> for such statements is used?
>
> Example:
>
> Given the declaration
>
> <T,C extends Collection<? extends T>> C apply(C source, #void(T) f);
>
> Can we invoke it like this:
>
> List<T> target = apply(String s: Arrays.asList("One", "Two", "Three")
> {
> // do something with "s"
> }
>
> In particular: do we now need a semicolon and the end of the assignment?
>
No, the syntax is specified as a statement - not an expression. Because it looks like a statement it is a statement. If it was an expression then it might confuse people and possibly compiler too. So unfortunatelly no return values from this syntax.
Peter
More information about the closures-dev
mailing list