Created
January 21, 2019 13:52
-
-
Save yannxou/853c3818824e19846f5d4fa1e88360de to your computer and use it in GitHub Desktop.
Float cast to nil (bug?)
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 characters
| import Foundation | |
| import UIKit | |
| func swiftVersion() -> String { | |
| #if swift(>=4.2.1) | |
| return "4.2.1" | |
| #elseif swift(>=4.2) | |
| return "4.2" | |
| #elseif swift(>=4.1) | |
| return "4.1" | |
| #elseif swift(>=4.0) | |
| return "4.0" | |
| #endif | |
| } | |
| let version = "Swift \(swiftVersion())" | |
| let value: Any? = 2.5 | |
| let a: Float? = value as? Float | |
| let f: CGFloat? = value as? CGFloat | |
| let b: Double? = value as? Double | |
| let c: Float? = (value as? NSNumber)?.floatValue |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result is nil for
aandf.