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

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -