[swift-evolution] [discussion] Class stored properties?

Mathew Huusko V mhuusko5 at gmail.com
Wed Aug 9 05:54:17 CDT 2017


Curious if class stored properties have ever been discussed (doesn't seem
so..)?

Also, assuming no, and assuming there's a good reason no/they're not coming
anytime soon, what are some patterns people have been using in their place?
I was considering something like..

class SomeClass {
    private static var _classValues = [SomeClass.Type: Int]()

    class var value: Int {
        get { _classValues[self] }
        set { _classValues[self] = newValue }
    }
}

.. but then I remembered types aren't hashable yet either (so I guess I
need to stringify it first).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170809/99d401b9/attachment.html>


More information about the swift-evolution mailing list