Defining Swift functions that operate on Types instead of values -
In Swift, How can I do my job, or the operators who work on type instead of values? What you want to achieve is not possible. Although there is a workaround: you can create a custom operator that is given a lexical or variable, converts it into optional Swift custom operators in Once done, you can use it as follows (Production from Playground): ? takes the operator instead of the
type as the parameter:
var z = 42? // an alternate & lt; Int & gt; And var z will not compile: int? = 42 //? Takes int and an alternate & lt; Int & gt;
? does not allow the use of the character, I am selecting a random combination, but do not hesitate to use your own:
Postfix Operator>! {} Postfix Funk & gt; & Lt; T & gt; (Value: T) - & gt; T? {Return value as T? }
10> // {some 10} Test "& gt; // {some "test"}
Comments
Post a Comment