Nick Harris

Swift Array with a Default Value

with 2 comments

I discovered this nifty little Swift array initializer tonight:

Screen Shot 2016 02 17 at 10 45 11 PM

Sweet! Set me up with a bunch of default objects!

Screen Shot 2016 02 17 at 10 48 29 PM

What the… Ugh.

Screen Shot 2016 02 17 at 10 49 09 PM

I get why but I really wanted 10 different NSObjects. 

Oh well.

Advertisements

Written by Nick Harris

February 18, 2016 at 5:56 am

Posted in Uncategorized

2 Responses

Subscribe to comments with RSS.

  1. You could do Array(anyGenerator({ NSObject() }).prefix(10))

    Koke

    February 18, 2016 at 11:39 am

    • Interesting, but much less clear. Thanks!

      Nick Harris

      February 19, 2016 at 1:21 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: