Module: Tins::RangePlus
- Defined in:
- lib/tins/range_plus.rb
Overview
Note:
This implementation converts both ranges to arrays and concatenates
RangePlus extends the Range class with additional functionality.
This module adds a ‘+` method to Range objects that concatenates the elements of two ranges into a single array.
them. This means it will materialize the entire range into memory, which could be problematic for very large ranges.
Instance Method Summary collapse
-
#+(other) ⇒ Array
Concatenates two ranges by converting them to arrays and merging them.
Instance Method Details
#+(other) ⇒ Array
Concatenates two ranges by converting them to arrays and merging them.
This method allows you to combine the elements of two ranges into a single array. Both ranges are converted to arrays using their ‘to_a` method, then concatenated together.
33 34 35 |
# File 'lib/tins/range_plus.rb', line 33 def +(other) to_a + other.to_a end |