I am new to ruby and started using it for the last few days, so my apologies if I am asking something very basic.
I am looking for a way to convert the following array into a hash.
arr =>
{"id"=>"xxx", "name"=>"show all", "parent_id"=>"yyy", "tsuite_name"=>"show system", "tc_external_id"=>"zzz"}
where arr.length is 1.
I tried to workaround it but could not convert it as a hash.
I needed this because Testlink xmlrpc responds with the format shown above.
Any help on this would be of great help.
Thanks.
Welcome to Ruby!
The below construct is a Hash.
If it was an Array, it would be surrounded by braces:
But what I think you were given was this:
The above object is a Hash within a Hash. The
lengthmethod reported 1 because the hash only contained a single key, namely,arr.You can test the class of a variable with the
classmethod:If all you need is the value of the inside hash, then grab it like so:
If I totally misunderstood your question, then please clarify.