Skip to content

Instantly share code, notes, and snippets.

@jamesrochabrun
Created July 19, 2020 18:09
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 jamesrochabrun/13c433a0a270b9b01c69a98947958fcc to your computer and use it in GitHub Desktop.
Save jamesrochabrun/13c433a0a270b9b01c69a98947958fcc to your computer and use it in GitHub Desktop.
import UIKit
class Vc: UIViewController {
var top: CGFloat? { 8 }
}
let viewController = Vc()
let a: CGFloat = 1.0
let b: CGFloat = 2.0
let result = (viewController as? Vc)?.top ?? a < b ? 10 : 15
print(result) // 15
print((viewController as? Vc)!.top ?? a < b) // flase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment