ので作ってみた。

hash_ext.rb

   1  class Hash
   2    def slice(*args)
   3      args = *args if args[0].is_a? Array
   4      args.inject({}){|hash, key| hash[key] = self[key]; hash}
   5    end
   6  end

使い方:

   1  conditions = params.slice :year, :month, :day

posted by Png genki on Wed 28 Nov 2007 at 04:16

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry225
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ