Sha256: 3412bda35de2918619851bdf2ac52d4cf794a93f2fa38d415b0db7cf3dbaaed5
Contents?: true
Size: 605 Bytes
Versions: 20
Compression:
Stored size: 605 Bytes
Contents
#!/usr/bin/env ruby # -*- encoding: utf-8 -*- # Copyright muflax <mail@muflax.com>, 2013 # License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html> class Array def triangle return to_enum(:triangle) unless block_given? self.each.with_index do |a, ai| self.each.with_index do |b, bi| next if bi < ai yield [a, b] end end end # silly accessors def second ; self[1] ; end def third ; self[2] ; end def fourth ; self[3] ; end def fifth ; self[4] ; end def rfind *arg, &block i = self.rindex(*arg, &block) i.nil? ? nil : self[i] end end
Version data entries
20 entries across 20 versions & 1 rubygems