新手问题 MatchData 问题

i5ting · 2013年03月04日 · 最后由 luikore 回复于 2013年03月04日 · 1666 次阅读

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 大神,想知道你是怎么知道?膜拜啊

需要 登录 后方可回复, 如果你还没有账号请 注册新账号