mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-11 17:24:29 +02:00
@@ -445,7 +445,10 @@ class MyShape: Rect {
|
|||||||
|
|
||||||
func grow() {
|
func grow() {
|
||||||
sideLength += 2
|
sideLength += 2
|
||||||
|
|
||||||
|
// Place a question mark after an optional property, method, or
|
||||||
|
// subscript to gracefully ignore a nil value and return nil
|
||||||
|
// instead of throwing a runtime error ("optional chaining").
|
||||||
if let allow = self.delegate?.canReshape?() {
|
if let allow = self.delegate?.canReshape?() {
|
||||||
// test for delegate then for method
|
// test for delegate then for method
|
||||||
self.delegate?.reshaped?()
|
self.delegate?.reshaped?()
|
||||||
|
Reference in New Issue
Block a user