[swift-evolution] .stride: using real ( floating point) number ranges

Dany St-Amant dsa.mls at icloud.com
Wed Mar 2 20:13:01 CST 2016


> Le 1 mars 2016 à 07:18, Ted van Gaalen via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> Hello Erica, you're right about this, adding, what you call an epsilon value to the end value in  .stride is indeed not very elegant, a "hack", so to speak. At least for the stride function, and also with possible other statements, the solution I bring forward here to solve this problem in a simple way is to specify a tolerance factor, like so: 
> 
> 0.0.stride( to: 100.0, by 0.1, comparisonTolerance: 0.01)
> 

Tolerance seem overkill, when a builtin epsilon of half the increment should do the trick, as long as half the increment is still visible to the range.

Dany


More information about the swift-evolution mailing list