We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6823908 commit 4c93318Copy full SHA for 4c93318
src/Optional.vsl
@@ -12,4 +12,18 @@ public struct Optional<Type> {
12
self.hasValue = true
13
self.value = value
14
}
15
+
16
+ /// Comparison overloads for optionals where T implements equatable. If you
17
+ /// wish to check for nil otherwise you can use the `===` operator which
18
+ /// checks reference equality. Internally, all VSL `nil` instances stem from
19
+ /// the same value
20
+ public static func ==(lhs: Optional<Type>, rhs: Optional<Type>) -> Bool {
21
+ if lhs.hasValue == true && rhs.hasValue == true {
22
+ // Otherwise compare the underlying values
23
+ return true // TODO: Implement with interfaces
24
+ } else {
25
+ // If one is nil then both must be nil for this to be true
26
+ return lhs.hasValue == rhs.hasValue
27
+ }
28
29
0 commit comments