-2

What will happen if I define a class like below code with Swift, the complier doesn't give any errors:

class Test {
    var test = Test()
}
Peruser
  • 11
  • 1

1 Answers1

0

Nothing strange happens.

It is perfectly legal for a class to hold a reference to an instance of the same class (i.e.: liked lists, trees, etc.)