Last active
August 29, 2015 14:02
-
-
Save drumnkyle/c5fbd7331a22ca98706f to your computer and use it in GitHub Desktop.
Problem with Swift GuidedTour enum with protocol challenge
This file contains 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 ExampleProtocol { | |
var simpleDescription: String { get } | |
mutating func adjust() | |
} | |
class SimpleClass: ExampleProtocol { | |
var simpleDescription: String = "A very simple class." | |
var anotherProperty: Int = 69105 | |
func adjust() { | |
simpleDescription += " Now 100% adjusted." | |
} | |
} | |
var a = SimpleClass() | |
a.adjust() | |
let aDescription = a.simpleDescription | |
struct SimpleStructure: ExampleProtocol { | |
var simpleDescription: String = "A simple structure" | |
mutating func adjust() { | |
simpleDescription += " (adjusted)" | |
} | |
} | |
var b = SimpleStructure() | |
b.adjust() | |
let bDescription = b.simpleDescription | |
// Can't get this to work. | |
enum SimpleEnum: ExampleProtocol { | |
case A, B | |
var simpleDescription: String = "A very simple enum." | |
mutating func adjust() { | |
simpleDescription += " Now 110% adjusted." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment