Skip to content

havenwood/hashy

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hashy

Build Status

A trivial implementation of three new Hash methods: map_pair, map_key & map_value. It's been proposed that these methods be added to the Ruby language. They're each just one-liners in Ruby but it seems they're quite handy.

Installation

gem install hashy

Usage

require 'hashy'

hash = { aim: true }
#=> {:aim=>true}

hash.map_pair { |k, v| [k.to_s, v.to_s] }
#=> {"aim"=>"true"}

hash.map_key(&:to_s)
#=> {"aim"=>true}

hash.map_value(&:to_s)
#=> {:aim=>"true"}

Credits

  • dsisnero's initial post on ruby-core
  • nobu's suggestion of appropriate method names and making a gem
  • heftig's refactoring of the code

Thanks all!

About

A Ruby Gem implementing three new Hash methods: map_pair, map_key, and map_value.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages