Swift Pocket Reference, 2E by Anthony Gray

Swift Pocket Reference, 2E by Anthony Gray

Author:Anthony Gray
Language: eng
Format: mobi, epub, pdf
Publisher: O'Reilly Media, Inc.
Published: 2015-11-11T05:00:00+00:00


var s = Square() s.width = 20.0 s.height = 10.0 s.area // returns 100.0 s.width // returns 10.0 (not 20.0)

When overriding properties, note the following:

You can override inherited read-only properties as read/write properties, by defining both a getter and setter.

You cannot override inherited read/write properties as read-only properties.

If you provide a setter, you must also provide a getter (even if it only returns the superclass property unmodified).

You can override inherited mutable properties (declared with var) with property observers, but you cannot override inherited immutable properties (declared with let) in this way (because property observers are intended to observe writes to the property).

You cannot override a property with both a setter and an observer (because the setter can act as the observer).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.