代码改变世界

Swift Error: '%' is unavailable, use truncatingRemainder instead

2018-12-11 10:40  法子  阅读(983)  评论(0编辑  收藏  举报

Swift3之后,非整数求余,不能再用%

let rem = 2.5.truncatingRemainder(dividingBy: 1.1)
print(rem) // 0.3

原文:https://stackoverflow.com/questions/40495301/what-does-is-unavailable-use-truncatingremainder-instead-mean