新手问题 MatchData 问题

i5ting · March 04, 2013 · Last by luikore replied at March 04, 2013 · 1660 hits

http://ruby-doc.org/core-1.8.7/MatchData.html

MatchData is the type of the special variable $~, and is the type of the object returned by Regexp#match and Regexp#last_match. It encapsulates all the results of a pattern match, results normally accessed through the special variables $&, $', $`, $1, $2, and so on. Matchdata is also known as MatchingData.

http://www.ruby-doc.org/core-2.0/MatchData.html

MatchData is the type of the special variable $~, and is the type of the object returned by Regexp#match and Regexp.last_match. It encapsulates all the results of a pattern match, results normally accessed through the special variables $&, $', $`, $1, $2, and so on.


2.0

mtch[i] → str or nil

1.8.7

mtch[i] => obj

这是啥意思呢?

因为 2.0 的 rdoc 可以指定除了 obj 以外的某些参数/返回类型了... 所以就能表达出更详细的 str or nil...

#1 楼 @luikore 大神,想知道你是怎么知道?膜拜啊

You need to Sign in before reply, if you don't have an account, please Sign up first.