-
-
Save zdman135/23960f995685739a55b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@array[0]['elements'][0]['comments'][0]['value'] = 'a string' | |
i=0 | |
while @array[0]['elements'][0]['comments'][0] != nil | |
name = @array[0]['elements'][0]['comments'][i]['value'] #put into hash where name is key and it equals the value | |
i += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If your dealing with a particular sub-node, and only that sub-node of a hash, you should probably store as a variable to remove the noise and duplication.
Another alternative is to use
comments.compact.reject(&:nil?)
, unless your using nil as a terminator (in which case, wat)