You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/GenericsManifesto.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -757,9 +757,9 @@ if e1 == e2 { ... } // error: e1 and e2 don't necessarily have the same dynamic
757
757
One explicit way to allow such operations in a type-safe manner is to introduce an "open existential" operation of some sort, which extracts and gives a name to the dynamic type stored inside an existential. For example:
758
758
759
759
```Swift
760
-
iflet storedInE1 = e1 openas T { // T is a the type of storedInE1, a copy of the value stored in e1
761
-
iflet storedInE2 = e2 as? T { //is e2 also a T?
762
-
if storedInE1 == storedInE2 { ... } //okay: storedInT1 and storedInE2 are both of type T, which we know is Equatable
760
+
iflet storedInE1 = e1 openas T { // T is the type of storedInE1, a copy of the value stored in e1
761
+
iflet storedInE2 = e2 as? T { //Does e2 have type T? If so, copy its value to storedInE2
762
+
if storedInE1 == storedInE2 { ... } //Okay: storedInT1 and storedInE2 are both of type T, which we know is Equatable
0 commit comments