25 Mar '12, 7am

@jmaicher Oh, right. Missed that. There are several solutions for mapping hashes to hashes:

Is there any good reason why Hash#map does not give back a Hash (Ruby 1.8 but same in 1.9 as far as I know)? I often find myself writing these kind of things: newhash = oldhash.inject({}) { |h,(k,v)| h[k] = some_operation(v); h } but that doesn't look pretty at all in my opinion. I want to just write like this: newhash = oldhash.map { |k,v| some_operation(v) } I finally got around to change this behaviour for my own code, but are all Ruby users supposed to invent this wheel on their own? Wouldn't it be better if Hash#map behaved like this? Or is there something I am missing? class Hash def hashmap self.inject({}) do |newhash, (k,v)| newhash[k] = yield(k, v) newhash end end end Regards, Fredrik

Full article: http://www.ruby-forum.com/topic/185611

Tweets

integrating PHP and Ruby On Rails - Ruby Forum

ruby-forum.com 24 Mar '12, 7am

check out if they have a REST-api and access this API using one of the numerous tools available like ActiveResource or Htt...

Mutable and Immutable Objects: Ruby Study Notes...

rubylearning.com 25 Mar '12, 5pm

Let us understand what we are doing here - a and b are two variables both of which are pointing to a string object - Origi...

Jay Fields' Thoughts: Ruby: Defining Class Meth...

blog.jayfields.com 25 Mar '12, 12am

"This [, Class.method,] is the version that recent Java/C# converts seem to prefer. I'm not a big fan of this version beca...

Did not realize that so many people had used my...

rubylearning.com 25 Mar '12, 1am

By Satish Talim RubyLearning.com is a thorough collection of Ruby Study Notes for those who are new to the Ruby programmin...

@joshbuddy in case you didn't see it. cc: @nesq...

engineyard.com 28 Mar '12, 8pm

Engine Yard, Inc. Log in Login to Engine Yard Cloud Login to Orchestra PHP Cloud Products Engine Yard Cloud Engine Yard Ma...

As per Google Analytics, the article "How do I ...

rubylearning.com 24 Mar '12, 11am

Please also note that highline makes many tasks such as user input simple. There’s main and Vision Commander and gli also....

WATCH: Forrester analyst @johnrrymer and learn ...

engineyard.com 27 Mar '12, 1am

In this educational video, Forrester VP and Principal Analyst John Rymer argues Platform as a Service (PaaS) holds the key...

Boston Rubyist @test_thoughtbot just blogged ab...

robots.thoughtbot.com 24 Mar '12, 8pm

My conscience won’t let me call Ruby a computer language. That would imply that the language works primarily on the comput...

Oldie but I enjoy this post on Ruby's inject me...

blog.jayfields.com 28 Mar '12, 8pm

I find the inject solution less readable than something like: a = [1,2,3,4,5,6].map{|x| x.to_s if 0 == x % 2}.compact or a...

Premium .In Forum Memberships ???? - Indian Dom...

inforum.in 25 Mar '12, 4pm

This is in no way Jeff asking me to post this. It is something I brought up as I keep on running out of mail space. I have...

@adamson_claire tech cartoon/how to guide via rails girls

@adamson_claire tech cartoon/how to guide via r...

mislav.uniqpath.com 24 Mar '12, 11pm

Concerning Commercial Uses of the (Poignant) Guide This book is released under a Creative Commons license which allows unl...

The Current State of Ruby concurrency

rubyflow.com 26 Mar '12, 12pm

The Current State of Ruby concurrency Posted by nmerouze on March 26, 2012 — 0 comments I'm currently in a project using W...

WATCH: Forrester analyst @johnrrymer to learn h...

engineyard.com 30 Mar '12, 11pm

In this video, Forrester VP and Principal Analyst John Rymer argues that companies need to include cloud as a strategic re...

Ruby Certification: Ruby Study Notes - Best Rub...

rubylearning.com 04 Apr '12, 8am

The Ruby Association Certified Ruby Programmer examinations are intended for such people as engineers who design, develop,...

Ruby Lugdunum 2012 - Ruby Conf in Lyon, France

rubyflow.com 27 Mar '12, 3pm

Ruby Lugdunum 2012 - Ruby Conf in Lyon, France Posted by pcreux on March 27, 2012 — 0 comments Ruby Lugdunum (a.k.a Rulu) ...