Created
February 28, 2017 10:04
-
-
Save n-soda/0dcd6092c72d140230bfd1cdd8364bcc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def recursive_conv_array_to_hash(h) | |
| h.each{|key, value| | |
| if value.is_a?(Array) | |
| hh = {} | |
| value.each{|e| hh[e]=0 } | |
| h[key] = hh | |
| else | |
| recursive_conv_array_to_hash value | |
| end | |
| } | |
| end | |
| h = {'a'=>{'aa'=>['aaa','aab']}, 'b'=>['bb','bc']} | |
| puts h | |
| recursive_conv_array_to_hash h | |
| puts h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment