ios - Swift initializer doesn't return value? -


swift documentation says.

unlike objective-c initializers, swift initializers not return value.

please explain below syntax.

let instanceofstring = string() 

it initialize string object calling initializer , return it. value assigned instanceofstring. isn't it?

the swift documentation refers syntax of type's init methods.

the syntax omits return type in signature , method not contain return statement:

init() { } 

obviously the call of initializer (string()) return value. difference objective-c init method in pure swift types not free return different object target of method—it's implicitly allocated instance of target type.

the exception it's possible return nil in failable initializers.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -