0

So I'm trying to access the test variable in this hash:

a = {:info=>#<test: "Testvar">}

I tried it with a[:info]['test'] or a[:info].test but I always get "can't convert Symbol into Integer" as error. What am I doing wrong? I guess it's pretty basic stuff but I can't find a solution.

4

1 回答 1

2

It looks like the #<test: "Testvar"> is just the string representation of an object, which would be accessible at a[:info]. You could try printing a[:info].inspect or a[:info].to_yaml to try to figure out what that object is.

于 2013-03-30T17:50:16.823 回答