trans. (T. Onoma) wrote:

>irb(main):001:0> a = 0..2
>=> 0..2
>irb(main):002:0> a.include?(1)
>=> true
>irb(main):003:0> a.include?(1.5)
>=> true
>irb(main):004:0> a = a.to_a
>=> [0, 1, 2]
>irb(main):005:0> a.include?(1)
>=> true
>irb(main):006:0> a.include?(1.5)
>=> false
>
>:(  
>
>T.
>
>  
>

What are you expecting the to_a method to actually do? Return a list of 
all the values within the range? Hint: infinite in number.

I realise that ranges are seemingly inconsistent:

irb(main):001:0> r = (1..5)
1..5
irb(main):002:0> r.each {|n| puts n}
1
2
3
4
5

Sometimes they behave like integers (as in each and to_a) and sometimes 
like floats (as in include). Converting a range to an array is like 
converting a float to an integer. You lose some information in the 
conversion. The wave partical duality of programming as it were.