Re: generics fun
Re: generics fun
- Subject: Re: generics fun
- From: "Shkutkov Michael" <email@hidden>
- Date: Tue, 22 Jul 2008 13:36:04 +0400
What about this solution
public class Test {
abstract class A{
}
class B extends A{
}
ArrayList<A> list;
void addAll(ArrayList<? extends A> list) {
for(A a: list) {
addElement(a);
}
}
void addElement(A element) {
list.add(element);
}
}
Does it suit you?
On Tue, Jul 22, 2008 at 2:08 AM, Lachlan Deck <
email@hidden> wrote:
On 22/07/2008, at 7:41 AM, Simon McLean wrote:
one of the things that frustrates me about generics is working with collections.
Just that one? Generics are the worst thing since Windows 3.11 ... I try to keep my code clean and add generics where they make sense but I hate them. There is absolutely NO GAIN in using them, just annoyance.
how about being able to do this :-
myarray.objectAtIndex(i).getMyKeypath();
without having to do a cast ?
i luuuuuurrrve generics!
Yeah, but it's implementation in Java sux.
Example:
NSMutableArray<? extends Foo> foos; // no problem
foos = new NSMutableArray<? extends Foo>(); // can't compile
Just stupid.
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (
email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to
email@hidden
--
Cheers, Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden