I have a class in swift with the following variable:
var pendingFunction = ((Double, Double) -> Double)
Swift then tells me:
Expected member name or constructor call after type name
It insists that I change my code to:
var pendingFunction = ((Double, Double) -> Double).self
I have no clue what this .self thing is doing (sorry I'm new to Swift)
I then try to assign pendingFunction to a new function:
pendingFunction = function
where function takes two Doubles and returns a Double.
However, I'm presented with the following error:
Cannot assign value of type '(Double,Double) -> Double' to type '((Double,Double)->Double).Type'
So my question is: what is the .self thing doing and how can I properly assign a function to the variable?
var pendingFunction: ((Double, Double) -> Double)to declare a variable of function type.var someInt: Intmeans you're going to assign a specific Int value to it, whilevar someInt = Int.selfmeans you're using it to represent the Int type as a whole.