For example how can i change the children name from “Training and
Culture” to let say “Objective”? Do i need to build a new hash for this
data and modify that hash? Thanks in advance.
I think working with this data will quickly become very difficult to
deal
with. For an example, see the latest Peepcode ( http://peepcode.com/products/play-by-play-bernhardt) where they spend
half
the screencast trying to figure out what their data looks like (its all
nested Hashes and Arrays, like yours). I think you should turn your data
into instances of some class[es] that defines how to deal with these
relationships in in a humane way.
Well, Arrays are ordered by nature. (Hashes shouldn’t be considered so).
That particular Hash was the first element of an Array.
So, it was the “0” element.
var[0] #=> “first” (a String)
var[1] #=> 2 (a Fixnum)
var[2] #=> {:third=>3, :not_third=>nil} (a Hash)
var[2][:third] #=> 3 (The :third key of that Hash is pointing to the
Fixnum 3)
var[2][:not_third] #=> true
4000 lines?!
I strongly agree with Josh.
You should use another kind of data representation.
If you have no choice with the input data, you can (recursively) parse
it and transform it into something human readable.
Actually, those contents will be converted into YAML format for other
purpose where indentation is very important. And i dont think other kind
of data representation is suitable for that purpose. Anyway, what do you
mean by ‘recursively parse’ it? And where can i find any tutorials or
examples that use ‘that’, if by any chance available on the net?
How do you know the hash inside it is indexed 0? This is because the
rest of the outputs consist of nearly 4000 lines. Thus, locating
contents wil be very difficult if i dnt know how to find it. Thanks