Last active
April 17, 2016 18:28
-
-
Save stevecass/0f4b79c088f128cbe7a1ec939d5739e2 to your computer and use it in GitHub Desktop.
Revisions
-
Steven Cassidy revised this gist
Apr 17, 2016 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,9 @@ let ex1: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": let ex2: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar]] /* If we omit import UIKit both both cases error with a different message error: value of type '[String]' does not conform to expected dictionary value type 'AnyObject' [Sratches head] */ -
Steven Cassidy revised this gist
Apr 17, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,5 +13,5 @@ let ex2: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": /* Without import UIKit both give error: value of type '[String]' does not conform to expected dictionary value type 'AnyObject' Sratches head */ -
Steven Cassidy revised this gist
Apr 17, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,17 @@ import UIKit let nonOptionalVar: [String] = ["a", "b", "c"] let optionalVar:String? = "jimmy" // this compiles OK with import UIKit present let ex1: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar!]] // Here we forget the ! character that unwraps the optional // error: contextual type 'AnyObject' cannot be used with dictionary literal let ex2: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar]] /* Without import UIKit both give error: value of type '[String]' does not conform to expected dictionary value type 'AnyObject' So UIKit seems to be doing something to affect interpretation of literals */ -
Steven Cassidy revised this gist
Apr 17, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,10 @@ let nonOptionalVar: [String] = ["a", "b", "c"] let optionalVar:String? = "jimmy" // compiles OK with import UIKit let ex1: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar!]] // error: contextual type 'AnyObject' cannot be used with dictionary literal let ex2: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar]] /* Without import UIKit both give -
Steven Cassidy created this gist
Apr 17, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ import UIKit let nonOptionalVar: [String] = ["a", "b", "c"] let optionalVar:String? = "jimmy" // compiles OK with import UIKit let ex1: [String: AnyObject] = ["hashtags" : nonOptionalVar, "tweet": ["content": optionalVar!]] // error: contextual type 'AnyObject' cannot be used with dictionary literal let ex2: [String: AnyObject] = ["hashtags" : nonOptionalVar, "tweet": ["content": optionalVar]] /* Without import UIKit both give error: value of type '[String]' does not conform to expected dictionary value type 'AnyObject' */