tproger
tproger

Reputation: 77

Init in Swift language

I read that

init

in Swift does not return value, then why i can write this :

var str = String.init("mystring")

Upvotes: 3

Views: 148

Answers (1)

Olivier Wilkinson
Olivier Wilkinson

Reputation: 2856

The function init doesn't return you are right, but in this case, you are just making a variable equal the struct String which is initialised with "hello"

It is the same as:

var class = someClass()

The () is an init function with no arguments.

Upvotes: 1

Related Questions