Block writing negative numbers in the error text box.

I would like to remove the code error: cannot use instance member 'number' within property initializer; property initializers run before 'self' is available from code:

let number = "some number"
let absolute = abs(number) // Here is error
That is normal, number is a String, not a number.

Do the conversion like here (nil coalescing needed in case the String is not of a number):

Code Block
let number = Float("-12") ?? 0 // Convert to Float, or Int("-12") if appropriate
let absolute = abs(number)
print(absolute)

you get
12.0

Don't forget to close the thread if that's OK.
Did you solve your issue ?
Block writing negative numbers in the error text box.
 
 
Q