Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
#eachを使ったら負け
Leonard Chin
June 27, 2012
Programming
7
1.3k
#eachを使ったら負け
Enumerable使いましょう!
each指数スクリプト:
https://gist.github.com/3008383
※2012/6/28の会社内LTで使用した資料
Leonard Chin
June 27, 2012
Tweet
Share
More Decks by Leonard Chin
See All by Leonard Chin
lchin
6
880
lchin
5
560
lchin
3
740
lchin
10
1k
Other Decks in Programming
See All in Programming
mackee
0
520
hyodol2513
0
580
lilobase
PRO
1
710
dqneo
3
300
yoshinoriiiii
0
110
kgmyshin
1
440
inoue2002
2
130
bkuhlmann
4
270
temoki
2
220
grapecity_dev
0
170
line_developers_tw2
0
810
mizotake
0
100
Featured
See All Featured
destraynor
223
47k
pauljervisheath
195
15k
samlambert
237
10k
addyosmani
1346
190k
tmm1
61
9.2k
trishagee
24
2.5k
marktimemedia
7
390
searls
205
36k
chrislema
231
16k
holman
288
130k
yeseniaperezcruz
302
31k
jcasabona
8
550
Transcript
#eachΛͬͨΒෛ͚
GPSΛ͍·͠ΐ͏
ʜ͡Όͳͯ͘
FBDIΛ͏ͱ͍͏͜ͱ
&OVNFSBCMFΛ͍ͬͯͳ͍ͬͯ͜ͱ
&OVNFSBCMFΛͬͱ͍·͠ΐ͏
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]
FBDIࢦ
IUUQTHJTUHJUIVCDPN
6TBHF
None
RVJDLEFNP
ҙɿશવݡ͘ͳ͍ूܭํ๏
ack --no-group --ruby "<method>[\s\.\{\(=]" <dir>
&OVNFSBCMFͷϝιου໊ͱ ඃͬͨΒ͑ͯ͠·͏
ͬͱ&OVNFSBCMFʹ͍ͭͯΓ͍ͨਓ
IUUQSVCZEPDPSHDPSF&OVNFSBCMFIUNM
$3VCZ enum.c
3VCJOJVT kernel/common/enumerable*.rb
͓·͚ɿ ͓͢͢Ίͷ&OVNFSBCMFϝιου
#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}