The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
A little Hash goodness

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
David Anderson

Posts: 26
Nickname: tfhma
Registered: Oct, 2005

David Anderson is a software generalist in Cincinnati doing Ruby and Rails in the agile style.
A little Hash goodness Posted: Sep 8, 2009 9:15 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by David Anderson.
Original Post: A little Hash goodness
Feed Title: def..end
Feed URL: http://feeds.feedburner.com/Defend
Feed Description: Ruby, Rails, and a smattering of other cruft from the back of Dave's mind.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by David Anderson
Latest Posts From def..end

Advertisement
Some quick refactoring this weekend had me throwing together some tidbits.module Enumerable # return Hash of enumeration to yielded values def collect_hash hash={} inject(hash) {|h,e| h[e] = block_given? ? yield(e) : nil; h } end # return Hash of enumeration to non-nil yielded values def select_hash hash={}, &block collect_hash(hash,&block).compact endendclass Hash # return Hash with

Read: A little Hash goodness

Topic: Debugging Ruby Scripts and Utilities Previous Topic   Next Topic Topic: Hirb Tips For Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use