• 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: Possible to defer initialization of let variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible to defer initialization of let variable?


  • Subject: Re: Possible to defer initialization of let variable?
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 07 Jul 2015 08:49:19 +0000

On Jul 7, 2015, at 01:39 , Rick Mann <email@hidden> wrote:
>
> The problem arises when you want to initialize more than one variable in that block of work.

If you ask the wrong question, you get a wrong answer. :)

You can use a tuple:

> let (thumbURL, isHero) =
> {
> 	() -> (String?, Bool) in
>
> 	for imgD in images
> 	{
> 		if let isHero = imgD["is_hero"] as? Bool where isHero,
> 			let t = imgD["thumbnail_signed_src"] as? String
> 		{
> 			return (t, isHero)
> 		}
> 	}
>
> 	return (nil, false)
> } ()

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Possible to defer initialization of let variable?
      • From: Rick Mann <email@hidden>
References: 
 >Possible to defer initialization of let variable? (From: Rick Mann <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Quincey Morris <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Rick Mann <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Quincey Morris <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Rick Mann <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Quincey Morris <email@hidden>)
 >Re: Possible to defer initialization of let variable? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Possible to defer initialization of let variable?
  • Next by Date: Re: Possible to defer initialization of let variable?
  • Previous by thread: Re: Possible to defer initialization of let variable?
  • Next by thread: Re: Possible to defer initialization of let variable?
  • Index(es):
    • Date
    • Thread