thanks , I finally ended by doing that .. and it runs well

On 24 fév, 13:03, Jim Ruther Nill <[email protected]> wrote:
> On Thu, Feb 24, 2011 at 6:27 PM, Erwin <[email protected]> wrote:
> > running irb in the console, I can transform easily an array into an
> > hash
>
> > > options = [["name", "aName"], ["integration_id", "604fe14d"],
> > ["api_secret", "b0a7088d"], ["site_id", 99], ["secure_base_url", "
> >https://www.mydomain.com:443/api/secure";], ["base_url", "
> >http://www.mydomain.com/api";]]
>
> > > options.inject({}) {|h,(k,v)| h[k]=v ; h}
> > {"name"=>"aName", "integration_id"=>"604fe14d",
> > "api_secret"=>"b0a7088d", "site_id"=>41, "secure_base_url"=>"https://
> >www.mydomain.com:443/api/secure", "base_url"=>"http://www.mydomain.com/
> > api"}
>
> > but running it in my code
>
> > def initialize(remote_server, options=nil)
> >  ...
> > @parameters = options.inject({}) {|h,(k,v)| h[k]=v; h }
> > ..
> > end
>
> why not try placing it in different lines.
> @parameters = options.inject({}) do |h,(k,v)|
>   h[k]=v
>   h
> end
>
> if it still gives the error, try splitting the second argument inside the
> block instead of using (k,v)
>
> running my app...
>
>
>
>
>
>
>
>
>
> >  syntax error, unexpected $end, expecting '}'
> > @parameters = options.inject({}) {|h,(k,v)| h[k]=v
>
> > it doesn't accept the semi-column !!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> -------------------------------------------------------------
> visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to