Skip to content

Instantly share code, notes, and snippets.

@ainame
Last active June 6, 2017 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ainame/713822b896a320e8acd8ccac5f359cc0 to your computer and use it in GitHub Desktop.
Save ainame/713822b896a320e8acd8ccac5f359cc0 to your computer and use it in GitHub Desktop.
Is this a bug on the Swift4?
import Foundation
let array: [String?] = ["a", "b", "c", "e"]
print(array) // => [Optional("a"), Optional("b"), Optional("c"), Optional("e")]
let strings = array.flatMap { $0! }
print(type(of: strings)) // => Array<Character>
@ainame
Copy link
Author

ainame commented Jun 6, 2017

expected: Array<String>

@ainame
Copy link
Author

ainame commented Jun 6, 2017

$ swift --version
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment