Closed RajChanchal closed 8 years ago
Yeah, Swift does not support automatic type casting.
For example you cannot do this either:
let aDouble: Double = 34.0
let anInteger: Int = aDouble
However, you can do this:
let aDouble: Double = 34.0
let anInteger = Int(aDouble)
And in the same way, you can also do this:
let myNumber: Double = 34.0
let money = GBP(myNumber)
This works for any MoneyType
. Please re-open if you still have issues.
let money: GBP=34.0
this is possible
but this isn't
var myNumber:Double = 34.0 let money:GBP = myNumber
Error is cannot convert value of type Double to specified type 'GBP'