zusammengesetzte properties, newValue
This commit is contained in:
parent
7d33f7849f
commit
8313451c1c
3 changed files with 8 additions and 3 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
|
@ -4,14 +4,19 @@ import Playgrounds
|
|||
struct Bike {
|
||||
var name: String
|
||||
var color: String
|
||||
|
||||
// newValue ist ein special keyword
|
||||
var description: String {
|
||||
set { name = newValue }
|
||||
get {"A bike called \(name) and it is \(color)." }}
|
||||
static let trek = Bike(name: "Trek", color: "red" )
|
||||
}
|
||||
|
||||
#Playground {
|
||||
var greeting = "Hallo Playground"
|
||||
let bike = Bike.trek
|
||||
bike.color
|
||||
var bike = Bike.trek
|
||||
bike.description
|
||||
bike.description = "Mein Rad"
|
||||
bike.description
|
||||
|
||||
// write code here
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue