• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: generics fun
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: generics fun
      • From: Lachlan Deck <email@hidden>
References: 
 >generics fun (From: Lachlan Deck <email@hidden>)
 >Re: generics fun (From: Guido Neitzer <email@hidden>)
 >Re: generics fun (From: Simon McLean <email@hidden>)
 >Re: generics fun (From: Lachlan Deck <email@hidden>)

  • Prev by Date: Re: generics fun
  • Next by Date: Re: generics fun
  • Previous by thread: Re: generics fun
  • Next by thread: Re: generics fun
  • Index(es):
    • Date
    • Thread