Sha256: 6ea060472ec86bf7e28f6d8916859f6affa701ee38715b3f98e193ef9f20e3a3
Contents?: true
Size: 720 Bytes
Versions: 19
Compression:
Stored size: 720 Bytes
Contents
#!/usr/local/bin/ruby -w # A template for new files in the project; of no interest to end users. An # error will be raised if you +require+ it. #-- # :enddoc: # # == extensions/XXX.rb # # Adds methods to the builtin XXX class. # raise "Do not load this file!" require "extensions/_base" # # * Enumerable#build_hash # ExtensionsProject.implement(Enumerable, :build_hash) do module Enumerable # # Like #map/#collect, but it generates a Hash. # # [1,5,11].build_hash { |x| [x, x**2] } # => { 1 => 2, 5 => 25, 11 => 121 } # def build_hash result = {} self.each do |elt| key, value = yield elt result[key] = value end result end end end
Version data entries
19 entries across 19 versions & 4 rubygems