Reputation: 77
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
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