Skip to content

Commit

Permalink
Fixed Regexp#named_captures to return an empty hash when there are
Browse files Browse the repository at this point in the history
no named captures.
  • Loading branch information
josh authored and Evan Phoenix committed Dec 9, 2009
1 parent 53ad731 commit f4fa1c3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kernel/common/regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,11 @@ def name_table
#
def named_captures
hash = {}
@names.each do |k,v|
hash[k.to_s] = [v + 1] # we only have one location currently for a key

if @names
@names.each do |k,v|
hash[k.to_s] = [v + 1] # we only have one location currently for a key
end
end

return hash
Expand Down

0 comments on commit f4fa1c3

Please sign in to comment.