snaulus (8) [Avatar] Offline
#1
The listing for Range declarations throws an exception on this line:

assert (0.0..1.0).contains(0.5)

Using Groovy 1.8 the range consists only of the numbers 0.0 and 1.0, there is no 0.5 anywhere in sight.

To correct, you can rewrite the line as follows:

assert !(0.0..1.0).contains(0.5)
chok (2) [Avatar] Offline
#2
Re: Error when running listing 4.1 on page 96
(0.1..1.2).each {
println it
}

println "size is ${(0.1..1.2).size()}"
assert 1.1 in (0.1..1.2)

output
0.1
1.1
size is 2

so I think range will step 1
so 0.5 is not member in range in this concept
not in math concept