More Typing Problems

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Tue Sep 7 21:20:49 PDT 2010


Hi all,

wildcards does not help(work).

what about this:

        DBSet<String>  result = allCustomer()
           .select(Customer#getName)
          .sortedByStringAscending(#(str){str});

best Regards,

Ali Ebrahimi

On Tue, Sep 7, 2010 at 12:43 PM, Rémi Forax <forax at univ-mlv.fr> wrote:

> Le 06/09/2010 23:39, Ming-Yee Iu a écrit :
> > I'm having more problems with getting my code to type properly. The
> > following piece of code does not compile due to typing problems:
> >
>
> Hi,
> you forget to put wildcards in you code
>
> >
> > public class Test
> > {
> >     public static class Customer {
> >        public String getName() { return "";}
> >     }
> >     public abstract static class StringSorter<U>  {
> >        abstract String value(U val);
> >     }
> >     public static interface Select<U, V>  {
> >        public V select(U val);
> >     }
> >     public static class DBSet<T>   {
> >        public<U>  DBSet<U>  select(Select<T,U>  x) {return new
> DBSet<U>();}
> >
>
> should be <U> DBSet<U> select(Select<? super T,? extends U> x)
> >        public DBSet<T>  sortedByStringAscending(StringSorter<T>  x)
> {return this;}
> >
>
> should be DBSet<T> sortedByStringAscending(StringSorter<? super T> x)
> >     }
> >
> >     public static DBSet<Customer>  allCustomer()
> >     {
> >        return new DBSet<Customer>();
> >     }
> >
> >     public static void main(String[] args)
> >     {
> >        DBSet<String>  result = allCustomer()
> >           .select(#(c){c.getName()})
> > //; result = result    // if you uncomment this line, then it compiles
> fine
> >           .sortedByStringAscending(#(str){str});
> >     }
> > }
> >
> > But if I uncomment the 4th line from the bottom, it then compiles fine.
> >
> > -Ming
> >
>
> Rémi
>
>


More information about the lambda-dev mailing list