Last active
August 29, 2015 14:20
-
-
Save davideme/e594e223dd07b0c7c888 to your computer and use it in GitHub Desktop.
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
// This protocol cannot be implemented by a enum. | |
// Because enums may not contain stored properties | |
protocol SomeProtocol { | |
var mustBeSettable: Bool { get set } | |
} | |
struct SomeStruct: SomeProtocol { | |
var mustBeSettable:Bool | |
} | |
// Compiler Error | |
//enum SomeEnum: SomeProtocol { | |
// var mustBeSettable:Bool | |
//} | |
class SomeClass: SomeProtocol { | |
var mustBeSettable:Bool = true | |
} | |
var s = SomeStruct(mustBeSettable: true) | |
s.mustBeSettable = false | |
var c = SomeClass() | |
c.mustBeSettable = false | |
// Compiler Error, SomeProtocol could be an enum | |
func someFunction(foo:SomeProtocol){ | |
foo.mustBeSettable = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment