[swift-evolution] Remove the Need for 'self' to Access 'dynamicType'

Mohamed Ebrahim Afifi mohamede1945 at gmail.com
Sun Apr 10 04:15:28 CDT 2016


Hi,

When access the `dynamicType` of a class inside one of its instance
methods. We should be using `self.dynamicType`. I purpose that the
dynamicType operator can be accessed without the need for the `self`.
So code like the following

class Foo {
    static let SomeStaticConstantValue = 5
    static func someStaticMethod() {
    }

    func bar() {
        self.dynamicType.someStaticMethod()
        print(self.dynamicType.SomeStaticConstantValue)
    }
}

can be translated to

class Foo {
    static let SomeStaticConstantValue = 5
    static func someStaticMethod() {
    }

    func bar() {
        dynamicType.someStaticMethod()
        print(dynamicType.SomeStaticConstantValue)
    }
}


Best Regards,
Mohamed Afifi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160410/40a4f689/attachment.html>


More information about the swift-evolution mailing list