Request for times, step, upto

//Robert Klemme schrieb:
//> "Peña, Botp" <botp@delmonte-phil.com> schrieb im Newsbeitrag
//>> int.times(starting=0, step=1) {|i| block }
//>>I hope this would not break old code, right?
//>
//> Sure, but semantics of this method will be broken. The
//block will no
//> longer execute int times. We have #step for that as know.
//
//I thought he just wanted to change the values passed into the
//block. Instead of
//
// 0, 1, ..., n-1
//
//it would be
//
// start, start + step, ..., start + (n-1)*step
//
//Looks useful to me.
//

Yes. you are right, sir Pit. Thank you for the explanation.
To give example, currently the family do it like this:

irb(main):011:0> class Integer
irb(main):012:1> def new_times start=0, step=1
irb(main):013:2> x=start
irb(main):014:2> self.times { |i|
irb(main):015:3* yield x
irb(main):016:3> x += step
irb(main):017:3> }
irb(main):018:2> end
irb(main):019:1> end
=> nil
# note the use of #times with #new_times above to emphasize
# similarity and suggested change

irb(main):020:0> 5.new_times {|x| p x}
0
1
2
3
4
=> 5
irb(main):021:0> 5.new_times(1) {|x| p x}
1
2
3
4
5
=> 5
irb(main):022:0> 5.new_times(1,2) {|x| p x}
1
3
5
7
9
=> 5

//Regards,
//Pit
//

kind regards -botp

···

Pit Captain [mailto:pit@capitain.de] wrote: