Hash Referencing Hack for Ruby

Category: Other - Tools & Utilities

I can never remember whether the Hash i am playing with has symbols for keys or strings. I also dont like typing the brackets (not all text editors have the cool "close brace" feature). That's why i came up with this method missing hack. Instead of explaining what it does, I'll just show you.Example:hsh = {"project"=>{ "prototype_url"=>nil, "designer_id"=>2, "finished_at"=>nil, "phone_number"=>"512225555", "website"=>"homepage", "first_name"=>"test", }}hsh.project#=> {"prototype_url"=>nil, "designer_id"=>2, "finished_at"=>nil, "phone_number"=>"512225555", "website"=>"homepage", "first_name"=>"test"}hsh.project.prototype_url #=> nilhsh.project.designer_id #=> 2hsh.project.first_name #=> test Date: 14 March, 2012


Hash Referencing - Ruby Hack - Ruby Snippets - Hash - Referencing - Ruby

Homepage: http://snippets.dzone.com/

Developer: snippets.dzone.com

License: Freeware

Operating System: All

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

Split an array of elements into a set of smaller arrays of equal size.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Split a string into an array of roughly equal sized chunks based on a string or regular expression delimiter.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Get the currently running method name in Ruby - how to get the running methos name in ruby.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Float Hacks:to_s override.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


A replacement for Ruby's File.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


The following code will create a live search in your Ruby on Rails project using AJAX.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Clone dev DB schema to test DB in Rails.

developer Developer: snipplr.com
license License: Freeware
operating systems Operating System: All


A Login Script is a simple php login snippet.

developer Developer: phpbuilder.com
license License: Freeware
operating systems Operating System: All


A random Number generator list.

developer Developer: dreamincode.net
license License: Freeware
operating systems Operating System: All