Created
November 1, 2011 05:16
-
-
Save yellow5/1329983 to your computer and use it in GitHub Desktop.
Working example converting array of string with single divider to hash
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
string_array = %w( key1=val1 key2=val2 key3=val3 ) | |
some_hash = {} | |
string_array.each do |array_element| | |
key,val = array_element.split('=') | |
some_hash[key.to_sym] = val | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment