More Typing Problems

Ming-Yee Iu mingyeeiu+lambda at gmail.com
Mon Sep 6 14:39:25 PDT 2010


I'm having more problems with getting my code to type properly. The
following piece of code does not compile due to typing problems:


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>();}
      public DBSet<T> sortedByStringAscending(StringSorter<T> x) {return this;}
   }

   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


More information about the lambda-dev mailing list