> > 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:in `size' > from (irb):4 > from :0 > > James Edward Gray II Well, that's slow but could... class Range def size inject(0){|s, dummy| s + 1} end end ...be a solution? cheers Simon
Re: Range#size
on 13.04.2006 15:46
