I assign an array to a hash value. When I inspect it shows the array
but when I try to access the array by the hash index it is nil.
Ideas?
Here is the log output of the inspect hash:
{:has_key=>0, :ext_array=>[“Text file (.txt)
”, “Rich Text Format
(.rtf)
”, “Word Document (.doc, .docx)
”]}
When I do:
h[:ext_array] it is nil.
Chris H. wrote:
I assign an array to a hash value. When I inspect it shows the array
but when I try to access the array by the hash index it is nil.
Ideas?
Here is the log output of the inspect hash:
{:has_key=>0, :ext_array=>[“Text file (.txt)
”, “Rich Text Format
(.rtf)
”, “Word Document (.doc, .docx)
”]}
When I do:
h[:ext_array] it is nil.
If u don’t mind can u give me the whole code.
On 18 March 2010 06:18, Me [email protected] wrote:
I assign an array to a hash value.
h[:ext_array] it is nil.
I copied your hash into IRB and it worked fine:
h = {:has_key=>0, :ext_array=>[“Text file (.txt)
”, “Rich Text Format
(.rtf)
”, “Word Document (.doc, .docx)
”]}
=> {:has_key=>0, :ext_array=>[“Text file (.txt)
”, “Rich Text
Format\n(.rtf)
”, “Word Document (.doc, .docx)
”]}
h[:ext_array]
=> [“Text file (.txt)
”, “Rich Text Format\n(.rtf)
”, “Word
Document (.doc, .docx)
”]
Can you post the code where you’re accessing h[:ext_array] and getting
nil. I think you might be getting nil as the result of an expression
rather than the value from the hash.
i am getting this same exact error message when i try to do a
User.find_by_username(‘array’). Im have twitter users signed up on my
site and i am trying to find the the users on my site from a
timeline.
When i try <%= User.find_by_username(‘status.user.screen_name’) %> It
returns nil, but if i use <%= status.user.screen_name %> it returns
all the user screen names so i can not figure out what is going wrong.
Take out the single quotes.