[swift-users] Why can't Swift instance methods call class methods without qualification?

zh ao owenzx at gmail.com
Fri Jul 1 11:38:14 CDT 2016

Swift forces you to use class name to alert you on the fact that static
variables and methods (may) affect the other instances of the class as
static variables are shared between instances. That does make sense.


On Fri, Jul 1, 2016 at 11:57 PM, Jens Alfke <jens at mooseyard.com> wrote:

> On Jun 30, 2016, at 6:47 PM, zh ao via swift-users <swift-users at swift.org>
> wrote:
> You should be aware of using static methods as it may change static
> variables, which affects all instances of that class. Normally I think
> static methods is designed to use outside the class instance, if you have
> to use it inside its instance method. You may need to rethink the pattern
> you do.
> This doesn’t make any sense to me. All class-based OO languages have
> static/class methods, so this isn’t specific to Swift. And *any* method
> can change static class variables. There’s nothing special about static
> methods that makes them less suitable for use by instance methods.
> —Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160702/79346bcc/attachment.html>

More information about the swift-users mailing list