Re: Range#size


#1

does anyone object to adding the method :size to class Range?

def size; max - min + 1 end
end
=> nil

(“AA”…“BB”).size
NoMethodError: undefined method -' for "BB":String from (irb):2:insize’
from (irb):4
from :0

James Edward G. II

Well, that’s slow but could…

class Range
def size
inject(0){|s, dummy| s + 1}
end
end

…be a solution?

cheers

Simon