Method: Range#downto
- Defined in:
- lib/combinatorics/extensions/range.rb
#downto(other) {|subrange| ... } ⇒ Enumerator
Iterates over every sub-range down to the other range.
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/combinatorics/extensions/range.rb', line 85 def downto(other) return enum_for(:downto,other) unless block_given? unless other.kind_of?(Range) raise(TypeError,"bad value for range",caller) end self.first.downto(other.first) do |start| self.last.downto(other.last) do |stop| yield start..stop end end end |