Iterable::forEach not returning Iterable
David Conrad
drconrad at gmail.com
Wed May 23 09:20:44 PDT 2012
On Tue, May 22, 2012 at 4:13 PM, Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:
> On 22/05/12 19:37, David Conrad wrote:
>
>> List<File> files...
>> files.filter( File::isFile ).map(tee((File f) -> { Log.log(f); return f;
>> })).filter( ... ).map( ConfigurationFile::new );
>>
>> I had to qualify the type of the lambda parameter, though; the compiler
>> couldn't infer it. Ah, well.
>>
> RIght, because the prototype doesn't support nested generic method call,
> so the call to tee nested into map yields Object for T - but stay tuned, as
> a solution is in the works ;-)
>
> Maurizio
>
Good news. :)
I hope it will also clear up this case, which I'm sure you're already aware
of (this is with the May 11 lambda build):
import java.util.Set;
import java.util.TreeSet;
import static java.util.Arrays.iterable;
public class Setty {
public static void main(String[] args) {
Set<Integer> s =
iterable(args).map(Integer::new).into(new TreeSet<>());
System.out.println(s);
}
}
dconrad at darwin ~/src/java
$ javac Setty.java
Setty.java:8: error: incompatible types
iterable(args).map(Integer::new).into(new TreeSet<>());
^
required: Set<Integer>
found: TreeSet<Object>
1 error
"I know what you meant, but I want to hear you say it." :)
Cheers,
David
More information about the lambda-dev
mailing list