-
-
Save bluwave/0991b734f3fbb16a55b3619124c7ee92 to your computer and use it in GitHub Desktop.
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
| // only class types: | |
| func myCast<MyClass: AnyObject>(value: AnyObject, type: MyClass.Type) -> MyClass? { | |
| return value as? MyClass | |
| } | |
| // any type (class, struct, etc): | |
| func myCast1<MyClass: Any>(value: Any, type: MyClass.Type) -> MyClass? { | |
| return value as? MyClass | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment