• 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: Lachlan Deck <email@hidden>
  • Date: Sat, 26 Jul 2008 14:26:23 +1000

On 23/07/2008, at 2:43 AM, Mike Schrag wrote:

This is worth watching if you are wanting to learn more about using generics (and enums):

http://www.youtube.com/watch?v=pi_I7oD_uGI
That's a great video ...

So I have a method which returns a batch of raw records like so:
(a) public Map< String, NSArray< NSDictionary< String, Object >> > nextBatch();


and elsewhere I've got a method like so (according to PECS)
(b) public NSArray<Foo> faultRecordsForRawRows(String entityName, NSArray<NSDictionary<String,? extends Object>>);


Guess what: the results of 'a' cannot be passed to 'b'.

// so we end up having to drop the typing like so:
for ( String entityName : currentRawBatch.keySet() )
{
// Note the following works but doing NSArray<NSDictionary<String,?>> doesn't.
NSArray< ? > rawRecords = currentRawBatch.get( entityName );
<..>
// and then do a cast for which I have to suppress warnings
NSArray<Foo> foos = controller.faultRecordsForRawRows( ( NSArray< NSDictionary< String, ? extends Object >> )rawRecords, entityName );
...
}


So that's a bit annoying. As I understand it it's not the done thing to have return values that 'extend' something. So is there any other suggestions?

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


References: 
 >generics fun (From: Lachlan Deck <email@hidden>)
 >Re: generics fun (From: Guido Neitzer <email@hidden>)
 >Re: generics fun (From: Ian Joyner <email@hidden>)
 >Re: generics fun (From: Guido Neitzer <email@hidden>)
 >Re: generics fun (From: Q <email@hidden>)
 >Re: generics fun (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: Unable to release locks held by deallocated EOEditingContext
  • Next by Date: Re: Unable to release locks held by deallocated EOEditingContext
  • Previous by thread: Re: generics fun
  • Next by thread: Re: generics fun
  • Index(es):
    • Date
    • Thread