From: duerst@... Date: 2014-12-25T06:50:40+00:00 Subject: [ruby-core:67122] [ruby-trunk - Feature #10645] Consider adding support of .first to MatchData object like MatchData[0] Issue #10645 has been updated by Martin D��rst. Robert A. Heiler wrote: > Would it be consistent to consider adding > support of .first to MatchData as well? > > class Array has it - I kind of assumed that > MatchData is a bit similar to Array. The question is how similar exactly. What other array methods would you expect? MatchData has a to_a method, so it can be treated as an array. Should it be changed to include Enumerable? Enumerable would have #first, and many other methods. ---------------------------------------- Feature #10645: Consider adding support of .first to MatchData object like MatchData[0] https://bugs.ruby-lang.org/issues/10645#change-50625 * Author: Robert A. Heiler * Status: Open * Priority: Low * Assignee: * Category: * Target version: ---------------------------------------- Hi, Lately I was using match data test_string = "
This is heading 6
" match = /\(.+)\<\/h\d+\>/.match(test_string) Then I tried to do this: puts match.first It did not work. puts match[0] Is the way to go. My question is: Would it be consistent to consider adding support of .first to MatchData as well? class Array has it - I kind of assumed that MatchData is a bit similar to Array. Thanks, -- https://bugs.ruby-lang.org/