Greetings all,
I have I have a cgi script written in eruby. I have turned cgi.param into a
hash object ‘p’
One of these parameters I need to use as an integer. It turns out this
parameter’s type is Array (?!?) and not a string like I thought.
i = p[‘count’].to_s.to_i
^^^^^^^^^ (yuck)
As you can see, I was able to turn this thing into an integer finally, but
it leaves me with two questions:
- Is there a prettier way to do what I am trying to do above?
- Why is it an Array, when I thought it would be a key -> value, where
value is a string
Thank you
P.S. What the heck,
2) What would be the situation where you would want it to be an Array?
i = p[‘count’].to_s.to_i
^^^^^^^^^ (yuck)
As you can see, I was able to turn this thing into an integer finally, but
it leaves me with two questions:
- Is there a prettier way to do what I am trying to do above?
i = p[‘count’].first.to_i
i = p[‘count’][0].to_i
i = p[‘count’].join().to_i
- Why is it an Array, when I thought it would be a key → value, where
value is a string
CGI supports parameter-value pairs where the parameter is not unique.
That means you can give multiple values for one parameter.
P.S. What the heck,
2) What would be the situation where you would want it to be an Array?
Checkboxes or multiple selections in a list.
-billy.
···
On Wed, Sep 18, 2002 at 02:44:08AM +0900, Vera, Michael wrote:
–
Meisterbohne Söflinger Straße 100 Tel: +49-731-399 499-0
eLösungen 89077 Ulm Fax: +49-731-399 499-9