It is a new language, ok. But why people can complex simple things? For years we used:
1 |
int newvar = (int)oldfloat; |
and it was ok. Not only in ObjectiveC but in many other. Now you have to:
1 |
var newintvar:Int = Int(oldfloatvar) |
BUT – keep in mind that float will be always ROUNDED DOWN – so for 1.9 you will get 1 not 2. To make it rounded as it should be use:
1 |
var newintvar:Int = Int(round(oldfloatvar)) |