I just created a class and gave it some vars. Unfortunately I can't access these variables in my iOS-Projects. However, the same syntax works in playground...
class ViewController: UIViewController
{
class Dog
{
var age = 0
var hungry = TRUE
}
var rex = Dog()
rex.age = 2 //ERROR: EXPECTED DECLARATION
}
The syntax for a class declaration is:
class <class name>: <superclass>, <adopted protocols> {
<declarations>
}
Your declaration of ViewController includes rex.age = 2 which itself is not a declaration, it is a statement - specifically a binary expression with an infix operator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With