[Swift-devel] Foreach with floats

Mihael Hategan hategan at mcs.anl.gov
Tue Jul 17 13:57:14 CDT 2012


Theoretically this should work:

foreach i in [0.0:10:0.2] {
}

(i.e. the first thing is a float and you specify a step).

But I seem to be getting an error when I try it.

Mihael

On Tue, 2012-07-17 at 13:30 -0500, David Kelly wrote:
> Hello,
> 
> Is it possible to use foreach with floating point numbers? Right now I can do something like this using ints:
> 
> foreach i in [0:10] {
>    tracef("i is %i\n", i);
> }
> 
> Is it possible to do something similar with floats using some delta value? For example, for every value between 0.0 and 10.0 in increments of 0.5?
> 
> David
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel





More information about the Swift-devel mailing list