Erwin
2011-Feb-24 10:27 UTC
I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
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 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jim Ruther Nill
2011-Feb-24 12:03 UTC
Re: I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
On Thu, Feb 24, 2011 at 6:27 PM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- ------------------------------------------------------------- visit my blog at http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Feb-24 12:11 UTC
Re: I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
On 24 February 2011 10:27, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> 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 > > running my app... > syntax error, unexpected $end, expecting ''}'' > @parameters = options.inject({}) {|h,(k,v)| h[k]=v > > it doesn''t accept the semi-column !!It syntax checks ok for me. I pasted it into one of my files and it is fine. Ruby 1.8.7. Are you sure it is not a problem in the surrounding code somewhere. Is it ok if you replace it with a simple line of code, or initially comment it out? Alternatively perhaps there is an non-printing character on that line that is confusing the parser. Try re-typing it completely. Colin -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Feb-24 18:21 UTC
Re: I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
thanks , I finally ended by doing that .. and it runs well On 24 fév, 13:03, Jim Ruther Nill <jvn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 24, 2011 at 6:27 PM, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Feb-24 18:25 UTC
Re: I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
I forgot to mention I write in Ruby 1.9.2... but whatever I should have the same error running irb ... I replaced this line with a do block and it''s running fine ... Did Einstein said : "Ruby don''t play dice" ? On 24 fév, 13:11, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 February 2011 10:27, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> 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 > > > running my app... > > syntax error, unexpected $end, expecting ''}'' > > @parameters = options.inject({}) {|h,(k,v)| h[k]=v > > > it doesn''t accept the semi-column !! > > It syntax checks ok for me. I pasted it into one of my files and it > is fine. Ruby 1.8.7. Are you sure it is not a problem in the > surrounding code somewhere. Is it ok if you replace it with a simple > line of code, or initially comment it out? Alternatively perhaps > there is an non-printing character on that line that is confusing the > parser. Try re-typing it completely. > > Colin-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2011-Feb-24 21:22 UTC
Re: Re: I am lost .. why this simple code is running well with irb and not in my app... (syntax error)
Quoting Erwin <yves_dufour-ee4meeAH724@public.gmane.org>:> I forgot to mention I write in Ruby 1.9.2... but whatever > I should have the same error running irb ... > I replaced this line with a do block and it''s running fine ... Did > Einstein said : "Ruby don''t play dice" ? >Ah, but God did give electrons a bit of freewill. Ruby interpreters may take similar libertes ;) Jeffrey -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.