Send function with hash

I know my x.to_s is not working and I need to use .send(something) but I cannot get the syntax right. If you can show me the correct send syntax I'd appreciate it.

h = Hash.new 
@cars.each do|x| 
  h["x.to_s"] = 0 
end

Answers


If you mean to use the string representation of x as a hash key, remove the quotation marks:

h[x.to_s] = 0

Need Your Help

Touchscreen specific stylesheets/commands

javascript jquery html touchscreen

Is there a way to detect if the user is on a touchscreen device? I want to change some HTML/jquery based on that fact (more specifically, jquery capSlide to show caption on touchscreen devices while

declaring struct inside of a class

c++ class struct

I am reading through a framework for a game, and it has a Door struct inside the Room class as follows:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.