Created
May 26, 2020 16:47
-
-
Save perpeer/780acebeb651f40554ef21d8ba8c9437 to your computer and use it in GitHub Desktop.
Toggleable Or Reversible Enum
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
| protocol Toggleable { | |
| mutating func toggle() | |
| } | |
| enum CardOrientation: String, Toggleable { | |
| case Horizontal = "hor" | |
| case Vertical = "ver" | |
| mutating func toggle() { | |
| switch self { | |
| case .Horizontal: | |
| self = .Vertical | |
| case .Vertical: | |
| self = .Horizontal | |
| } | |
| } | |
| } | |
| var orientation: CardOrientation = .Horizontal | |
| orientation.toggle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment