different between these two array method.

Dear friends,

What is different between these two array method.

First Array Method

      arr = ps_array["1"]
      arr += ps_array["2"]
      arr += ps_array["3"]

Second Array Method

      arr = [ps_array["1"],ps_array["2"],ps_array["3"]]

yours,

phoesan

Dear friends,

What is different between these two array method.

First Array Method

      arr = ps_array["1"]

What is the type of ps_array["1"]

Colin

<%= collection_select(:sport_name,count,Sport.find( :all, :order => 'id'
),
            :id, :sport_name, {:selected =>@sport_id})%>

Collection_select Value.
We take data from collection_select by params[:sport_name]

In Controller, we use this
ps_array = params[:sport_name]
we get the data

First array method , It doesn't work.
Second Method , It Work.

Regards,

phoesan

Hi,

  • operator won’t works in array I think but used as concatenation in staring.

Second scenario of your case works fine.

Thanks,
senthil

Please remember to quote the previous message, remember this is a
mailing list not a forum (though you may be accessing it via a forum
interface). Now we will have to look back at the previous message to
see your methods.

When you say
arr = ps_array["1"]
arr is probably a string not an array, so then when you use
arr += ps_array["2"]
it will concatenate the second string onto the first.

Have a look at the Rails Guide on debugging for ideas on how to debug
your code so that you can work out what is going on when you have this
sort of problem.

Colin

Hi Sentil and Colin,

ႊThank for your reply message and solution!

phoesan