Symbol Replacement in Ruby -
I have a map created by others like data structure:
x = { "City": "London", "Country": "England", "Area": "Europe"}
I want to manipulate data in Ruby I To be able to make it a map, let me all ":"
to "=>
Is this a quick way to complete a line?
my_text = 'x = {"city": "London", "country": = "Ruby_code = t.gsub (':', '=>') with #define:" England "," region ":" region ":" Europe "} # # Change: Ruby code as eval ruby_code # Now you Hash x ['city'] # => "London"
Comments
Post a Comment