Sha256: 3f9a36101b97fe22e43f05bfef201c003974e651359ef7c1522eeb3bc0fc734b
Contents?: true
Size: 588 Bytes
Versions: 3
Compression:
Stored size: 588 Bytes
Contents
# The {Enumerable} module. module Enumerable # Returns an array containing the items in the receiver. # # @example # # (1..4).to_a # => [1, 2, 3, 4] # [1, 2, 3].to_a # => [1, 2, 3] # # @return [Array] def to_a ary = [] each { |arg| `ary.push(arg);` } ary end alias_method :entries, :to_a def collect(&block) raise "Enumerable#collect no block given" unless block_given? `var result = [];` each do |*args| `result.push(#{block.call *args});` end `return result;` end alias_method :map, :collect end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.10 | corelib/enumerable.rb |
opal-0.3.9 | corelib/enumerable.rb |
opal-0.3.6 | lib/core/enumerable.rb |