I am having an issue trying to figure out how to work with an array inside a hash in ruby. I am running a command (last command on linux if you must know), capturing output from it and trying to insert unique data about each user that appeared in this log into the hash, each having its own array. Example below:
hash = {
"userbob1" => ["Bob User", 10, "10.10.2016"],
"userjim2" => ["Jim User", 4, "9.16.16"]
}
and so forth.
I have been able to successfully insert an array into a hash as a whole, but how would I go about retrieving specific values of that array, or adding values to it after I added it to the hash?
I'd imagine something like this:
hash["userbob1"[0]] #=> "Bob User"
"userjim1",Bob Userand10.10.2016are not valid Ruby objects. I expect you want["Bob User", 10, "10.10.2016"]and similar for"userjim2".