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

Rick Mann rmann at latencyzero.com
Thu Jun 30 19:59:13 CDT 2016


Why can my instance methods not call class methods without the class specifier?

class MyClass
{
   func
   foo()
   {
       classMethod()
   }

   class
   func
   classMethod()
   {
   }
}

Why do I have to call MyClass.classMethod()? Just a choice made by the language designers to distinguish the call at the call site? I like C++'s way of treating all static methods as directly available to the instance.

-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list