Skip to content

Instantly share code, notes, and snippets.

@tgnivekucn
Created December 8, 2021 05:30
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 tgnivekucn/7e6576cd46df2fcff97f55929b50684e to your computer and use it in GitHub Desktop.
Save tgnivekucn/7e6576cd46df2fcff97f55929b50684e to your computer and use it in GitHub Desktop.
Part of Optional.swift
public enum Optional<Wrapped>: ExpressibleByNilLiteral {
case none
case some(Wrapped)
public init(_ some: Wrapped) { self = .some(some) }
public init(nilLiteral: ()) {
self = .none
}
@inlinable
public static func ==(lhs: Wrapped?, rhs: Wrapped?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l == r
case (nil, nil):
return true
default:
return false
}
}
.....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment