I just read that a method initcannot be used as a value. Value:
init
var x = SomeClass.someClassFunction // ok var y = SomeClass.init // error
Example found in Language Link
Why should this be? Is this a way to ensure a language level that creates too dirty tricks due to some consistency, or maybe because it interferes with another function?
Unlike Obj-C, where a function initcan be called several times without problems, there is actually no method called in Swift init.
init - , " ". MyClass() . myInstance.init(). , .
MyClass()
myInstance.init()
, .
var y = SomeClass.init
?
init - , .
, , init . , , , init, , .
Initializers have no return value. In order to appropriate something to him, he must be able to return something - and this is not so.
Source: https://habr.com/ru/post/1543122/More articles:Oracle возвращает десятичное значение для определенного столбца NUMBER (4) - c#Fuzzy logical demonstration of veracity - javaProduct Description Google In-App Billing - androidUsing Python to auto-fit all columns in an Excel worksheet - pythonIs there a tool to identify obsolete / inconsistent JavaDoc comments? - javapip install on OS X Mavericks with the error: / usr / local / bin / pip: There is no such file or directory - pythonUninitialized constant Capybara - ruby | fooobar.comИспользование rails-perftest с Rails 4.1 и Ruby 2.1 - performance-testingОтправка события Touch из окна "Диалоговое изображение" в представление родительской активности - androidHighlighting the shortest path in a Networkx diagram - python-2.7All Articles