Project

General

Profile

Feature #14249

Remove str[match_str]

Added by ana06 (Ana Maria Martinez Gomez) 4 months ago. Updated 4 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:84514]

Description

I wonder if str[match_str] makes sense.

"ana"['a'] => "a"

I would say this is not expected and it brings problems, for example when accessing nested hashes. For example:

params = { "user" => "Nicolas Cage" } => {"user"=>"Nicolas Cage"}

params["user"]["age"] => "age"

I think str[regexp] is enough and that str[match_str] can be removed.

History

#1 Updated by ana06 (Ana Maria Martinez Gomez) 4 months ago

  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
  • ruby -v deleted (2.4)
  • Tracker changed from Bug to Feature

#2 [ruby-core:84517] Updated by naruse (Yui NARUSE) 4 months ago

Use Hash#dig instead.

Also available in: Atom PDF