Upgrade to Pro — share decks privately, control downloads, hide ads and more …

#eachを使ったら負け

 #eachを使ったら負け

Enumerable使いましょう!

each指数スクリプト:https://gist.github.com/3008383

※2012/6/28の会社内LTで使用した資料

Leonard Chin

June 27, 2012
Tweet

More Decks by Leonard Chin

Other Decks in Programming

Transcript

  1. Enumerable.instance_methods.sort => [:all?, :any?, :chunk, :collect, :collect_concat, :count, :cycle, :detect,

    :drop, :drop_while, :each_cons, :each_entry, :each_slice, :each_with_index, :each_with_object, :entries, :find, :find_all, :find_index, :first, :flat_map, :grep, :group_by, :include?, :inject, :map, :max, :max_by, :member?, :min, :min_by, :minmax, :minmax_by, :none?, :one?, :partition, :reduce, :reject, :reverse_each, :select, :slice_before, :sort, :sort_by, :take, :take_while, :to_a, :zip]
  2. #each_with_object # Better than inject for building hashes %w(one two

    three).each_with_object({}) {|w, hash| hash[word] = word.length } # => {"one"=>3, "two"=>3, "three"=>5}