RE: [Ikvm-developers] Ghosts and generics
Brought to you by:
jfrijters
From: Jeroen F. <je...@su...> - 2003-10-22 13:44:24
|
Jonathan,=20 You wrote: > >>If I statically know that the type is a string, > >>why do I need all this complicated stuff? I can just call > >>StringHelper.charAt(). >=20 > The example wasn't complete enough to illustrate the point.=20 > You can't just call StringHelper since you don't know to > use it from the string type in a generic way. >=20 > The idea is to use overloaded methods so you can just plug in=20 > the type in the generic call. You don't need to know to use the=20 > StringHelper class for strings, you can just call the generic > charAt method with the string type like I do in this updated > version of the example: Why use generics? I must still be missing something, but wouldn't it be much easier to use overloading: public class CharSequenceHelper { public static char charAt(string s int i) { ... } public static char charAt(CharSequence s, int i) { ... } } BTW, what do you think of my new value type approach? Regards, Jeroen |