ios - Stored type properties for classes in Swift -


i've seen similar questions on so, none has answer question. "the swift programming language" book (v. 1.2) says:

for classes, can define computed type properties only

and on next page have following example (i got rid of code sake of brevity):

class someclass {     static var storedtypeproperty = "some value."     // ... } 

even name of variable says it's stored type property (not computed one).

update: can define stored properties classes, see detailed answer below. turned out book wasn't updated changes in swift 1.2 part.

static stored properties in classes introduced swift 1.2. xcode 6.3 release notes list under swift language enhancements (emphasis added):

static” methods , properties allowed in classes (as alias class final). allowed declare static stored properties in classes, have global storage , lazily initialized on first access (like global variables).

the example

class someclass {     static var storedtypeproperty = "some value."     // ... } 

is example static property of class. statement

for classes, can define computed type properties only

is not correct, has not yet been updated according language change.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -