Design for collections upgrades

Llewellyn Falco isidore at
Thu Mar 10 06:27:24 PST 2011


Iterable<T>  filter(Predicate<Boolean> p)

is the method.

It should not and can not do the following

Set s = myset.filter( #{s->s > 3} )

why? because you can't change the signature to return a Set. You could
make it so you have this

Set s = (Set)myset.filter( #{s->s > 3} )

but then you run into the following with map

assertEqual(3, new Set("a","b","c").map( #s-> s.length() ).count())

how are you going to get that spec to pass?
or will map do a fundamentally different thing than filter?


More information about the lambda-dev mailing list