Reputation: 4050
I have this type of hash stored in variable foo
{:name=>"bobby", :data=>[[1, 2], [3, 4], [5, 6], [7, 8]]}
when I try foo[:data]
I get no implicit conversion of Symbol into Integer
How do I get the 2d array?
EDIT
This is the entire code:
redis = Redis.new
redis.set "foo", {name: "bobby", :data => [
[1,2],[3,4],[5,6],[7,8]
]}
foo = redis.get "foo"
puts foo[:data][0]
Upvotes: 0
Views: 587
Reputation: 44685
redis.get
returns a string, not a hash. This string is JSON representation of the hash. Try:
require 'json'
foo = JSON.parse(redis.get "foo")
puts foo['data']
Upvotes: 1