Why this doesn’t work?
session[:aa][:bb] = “xxx”
Why this doesn’t work?
session[:aa][:bb] = “xxx”
On 19 Jan 2009, at 18:05, James B. wrote:
Why this doesn’t work?
session[:aa][:bb] = “xxx”
probably because session[:aa] is nil
Fred
Frederick C. wrote:
On 19 Jan 2009, at 18:05, James B. wrote:
Why this doesn’t work?
session[:aa][:bb] = “xxx”
probably because session[:aa] is nil
Fred
How to “fix” it?
index 25009 out of string
I can’t make this work:
@tmp = “xxx”
session[@tmp][:yyy] = “zzz”
On 19 Jan 2009, at 18:39, James B. wrote:
Fred
How to “fix” it?
index 25009 out of string
that sounds like session[:aa] is a string.
There’s nothing wrong with session[:aa][:bb] = “xxx” assuming the
objects involved are of the right type, which will be down to the rest
of the code in your app
Fred
On Jan 19, 2009, at 3:53 PM, James B. wrote:
I can’t make this work:
@tmp = “xxx”
session[@tmp][:yyy] = “zzz”
and unless you tell us what you expect to happen, no one else can
either.
Do you expect the Hash implied by session[@tmp] to spring into
existence so you can assign a value to the :yyy key?
In that case, session would have to refer to something like:
Hash.new {|h,k| h[k] = {} }
So:
session = Hash.new {|h,k| h[k] = {} }
@tmp = “xxx”
session[@tmp][:yyy] = “zzz”
puts session.inspect
{“xxx”=>{:yyy=>“zzz”}}
-Rob
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs