• 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: Noob Swift frustration with dicts and optionals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Noob Swift frustration with dicts and optionals


  • Subject: Re: Noob Swift frustration with dicts and optionals
  • From: Marco S Hyman <email@hidden>
  • Date: Wed, 17 Sep 2014 15:37:00 -0700

>
> The message still seems wrong, though: the operand of the "?" is the dict lookup, which _is_ optional.

Many Swift error messages leave me scratching my head. My latest
head scratcher was this:

func someFunc() -> String {
    return "foo"
}

let key = someFunc()

switch key {
case "foo", "bar", "baz":
    println(key)
default:
    println("Key not found")
}

Works fine.  But when someFunc (in another file) changes to return
a "String?" instead of a "String" the compiler tells me that "foo",
"bar", and "baz" does not conform to protocol 'IntervalType'.

Marc
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Noob Swift frustration with dicts and optionals
      • From: Roland King <email@hidden>
References: 
 >Noob Swift frustration with dicts and optionals (From: Jens Alfke <email@hidden>)
 >Re: Noob Swift frustration with dicts and optionals (From: Marco S Hyman <email@hidden>)
 >Re: Noob Swift frustration with dicts and optionals (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Noob Swift frustration with dicts and optionals
  • Next by Date: Re: Noob Swift frustration with dicts and optionals
  • Previous by thread: Re: Noob Swift frustration with dicts and optionals
  • Next by thread: Re: Noob Swift frustration with dicts and optionals
  • Index(es):
    • Date
    • Thread