Matchdata#end one character after match?

I know this is probably just the way it works, but I was a bit antiPOLSed.

irb(main):016:0> md = /X/.match("yzXrb")
=> #<MatchData:0x402fbe8c>
irb(main):018:0> p md.begin(0)
2
=> nil
irb(main):017:0> p md.end(0)
3
=> nil

3 and not 2?

···

--
( o _ カラチ
// T. / trans.
/ \ transami@runbox.com

I don't give a damn for a man that can only spell a word one way.
-Mark Twain

"trans. (T. Onoma)" <transami@runbox.com> schrieb im Newsbeitrag news:200409231333.49887.transami@runbox.com...

I know this is probably just the way it works, but I was a bit antiPOLSed.

irb(main):016:0> md = /X/.match("yzXrb")
=> #<MatchData:0x402fbe8c>
irb(main):018:0> p md.begin(0)
2
=> nil
irb(main):017:0> p md.end(0)
3
=> nil

3 and not 2?

Yes, and it's reasonable: all sorts of computations are a lot easier with this convention. For example:
length = m.end(0) - m.begin(0)
empty = m.begin(0) == m.end(0)
etc.

All libs that deal with sub sequences reasonable do it this way. *I* would have been surprised if it was otherwise.

Regards

    robert