Is there any way to push elements onto the end of a range without converting it into an array then back to a range?
r = 1..10
=> 1..10
r << 11
NoMethodError: undefined method `<<' for 1..10:Range
r.push 11
NoMethodError: undefined method `push' for 1..10:Range
A range is simply an interval. A start and an end. You don’t just push values on the end of a Range. You either convert the Range to an array
Or you create a new range..
EDIT: The reason we use #begin on the range and not #first is because
firstandlastbuild a new array from the Range, we don’t want that.. we just want thebeginorendvalues instead.