The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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