Sha256: 211f679e2aa83e88d1374e65d432a40f9fafa3bb86c0102fece15095f8f5be09
Contents?: true
Size: 329 Bytes
Versions: 1
Compression:
Stored size: 329 Bytes
Contents
# encoding: utf-8 # Enumerable module Enumerable # === Example # # [*1..4].if_else_map(:odd?.to_proc,->(odd){'奇数'},->(even){'偶数'}) # => ['奇数','偶数','奇数','偶数'] # def if_else_map(predicate, proc_t, proc_f) map { |e|predicate.call(e) ? proc_t.call(e) : proc_f.call(e) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tbpgr_utils-0.0.151 | lib/open_classes/enumerable/if_else_map.rb |