On 16 Oct 2008, at 9:01 am, Daryoush Mehrtash wrote:
I am not sure how say in a Java language a constructor can "conjure up a value of an unknown type".

... Class anUnknownClass;
    Object anInstance;
    anInstance = anUnknownClass.getConstructor().newInstance();

If you know that the constructor will require arguments of
types T1 and T2, and you have suitable values v1, v2,

    anInstance =
      anUnknownClass.getConstructor(T1, T2).newInstance(v1, v2);

will do the job.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to