Constructors in Swift

Viewed 30641

I need some help in constructors in swift. I am sorry, if this question is incorrect or repeated, but I didn't found an answer to my question in another links. So, I have a class

class myClass {
  override init(){
    print("Hello World")
  }
}

And I have an another class

class anotherClass {
 let variable = myClass()
 }

Could somebody correct this code? Because it gives me error. I don't know how to explain my question in Swift, because I am newbie. But I will try to explain it, I want to say that when I create an object of the class "myClass", firstly constructor should work and print "Hello World". Thank you!

1 Answers
Related