1

Normally we should use keyword class to define a class computed property, like

class Square{
    class var area:Float{
        return 100.0*100.0
    } 
}

However we can not use class to define a stored property (I know it results from OC).

And meanwhile we may use static in a class to define a stored property and it runs successfully.

enter image description here

So my question is: what are the differences between static and class when used in a class?

0

2 Answers 2

1

The main difference between static and class is that class elements can be overridden.

As a short way to say this, static has the same effect that final class.

You can refer to this question to have more details.

Sign up to request clarification or add additional context in comments.

Comments

0

I would refer to this, basically, you can override a class func/var, but you cannot a static one.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.