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で使用した資料

70762059db0218c6f0ff48042ca0756a?s=128

Leonard Chin

June 27, 2012
Tweet

Transcript

  1. #eachΛ࢖ͬͨΒෛ͚

  2. GPSΛ࢖͍·͠ΐ͏

  3. ʜ͡Όͳͯ͘

  4. FBDIΛ࢖͏ͱ͍͏͜ͱ͸

  5. &OVNFSBCMFΛ࢖͍ͬͯͳ͍ͬͯ͜ͱ

  6. &OVNFSBCMFΛ΋ͬͱ࢖͍·͠ΐ͏

  7. 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]
  8. FBDIࢦ਺

  9. IUUQTHJTUHJUIVCDPN

  10. 6TBHF

  11. None
  12. RVJDLEFNP

  13. ஫ҙɿશવݡ͘ͳ͍ूܭํ๏

  14. ack --no-group --ruby "<method>[\s\.\{\(=]" <dir>

  15. &OVNFSBCMFͷϝιου໊ͱ ඃͬͨΒ਺͑ͯ͠·͏

  16. ΋ͬͱ&OVNFSBCMFʹ͍ͭͯ஌Γ͍ͨਓ΁

  17. IUUQSVCZEPDPSHDPSF&OVNFSBCMFIUNM

  18. $3VCZ enum.c

  19. 3VCJOJVT kernel/common/enumerable*.rb

  20. ͓·͚ɿ ͓͢͢Ίͷ&OVNFSBCMFϝιου

  21. #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}