Method: Range#upto
- Defined in:
- lib/combinatorics/extensions/range.rb
#upto(other) {|subrange| ... } ⇒ Enumerator
Iterates over every sub-range up to the other range.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/combinatorics/extensions/range.rb', line 49 def upto(other) return enum_for(:upto,other) unless block_given? unless other.kind_of?(Range) raise(TypeError,"bad value for range",caller) end self.first.upto(other.first) do |start| self.last.upto(other.last) do |stop| yield start..stop end end end |