I’m farily new to the ruby language and I came across this line of code:
f.options[:chart][:defaultSeriesType] = "bar"
Could somebody please explain that one to me? Because doing this:
f.options([:chart][:defaultSeriesType]) = "bar"
Gives you an error.
Thanks in advance!
You are handling with an hash.
When you have doubts like that do
f.options.inspect, it will print out the content of the data structure.I’ll let you understand with an example:
Based from the way you wrote, it seems that you are handling an object organized more on less in this way :
So you can query the object by writing:
f.options[:graph][:attribute1]orf.options[:chart][:somethingElse]and so on.I suggest you to spend one minute on http://www.tryruby.org and playing with the hash, you could also take a look here: http://www.troubleshooters.com/codecorn/ruby/basictutorial.htm#_Hashes
Sure it helps