Range object as a parameter

I trying to use a range object from an array of ranges objects as a
parameter

my_range = [(0…2), (2…5), (5…10), (10…15), (15…25)]

props = []
domains = Domain.find(:all)

keep track of the number of domains

@ props[0] = domains.nitems
k = params[:id] # can be 0, 1 ,2,3,4

1.step(domains.nitems,1) do |d|
props[d] = Proposition.find_by_range( ( my_range[k ] ) , …
)
d = d.next
end

I got an error : can’t convert String into Integer in the line :
props[d] = Proposition.find_by_range( ( my_range[k ] ) , … )

is is wrong ?

thanks for your help

joss

Josselin wrote:

k = params[:id] # can be 0, 1 ,2,3,4

1.step(domains.nitems,1) do |d|
props[d] = Proposition.find_by_range( ( my_range[k ] ) , … )
d = d.next
end

I got an error : can’t convert String into Integer in the line :
props[d] = Proposition.find_by_range( ( my_range[k ] ) , … )

is is wrong ?
Here’s a guess: k is a String? Array indices can only be Integers -
try my_range[k.to_i].

On 2007-05-28 20:09:43 +0200, Alex Y. [email protected] said:

k = params[:id] # can be 0, 1 ,2,3,4
Here’s a guess: k is a String? Array indices can only be Integers -
try my_range[k.to_i].

thanks that’s it… I was not searching for the right problem… could
not find the right solution…

4 years better than 2… don’t know why we have been created like that
! (or “evolutionned”… ;-)))