class level or struct level method in swift like static method in Java?

后端 未结 3 2040
[愿得一人]
[愿得一人] 2021-02-02 06:10

Is there a way to add method at class level or struct level in swift?

struct Card {
    var rank: Rank
    var suit: Suit
    func simpleDescription() -> Stri         


        
3条回答
  •  情深已故
    2021-02-02 06:57

    p 353

    class SomeClass {
        class func someTypeMethod() {
            // type method implementation goes here
        }
    }
    SomeClass.someTypeMethod()
    

    Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l

提交回复
热议问题