You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for Regex uses a lot of not_nil! in the code examples, and is one of only 4 pages to do this, but it should not be like this. It is generally recommended to not use this method where possible (or unless absolutely necessary, IMO) and the Regex docs should reflect that.
Most (if not all) of the examples are to do with the String#match method which is nilable, so I have created #13119 to address that, but another solution could be to recommend the conditional statement check syntax. For example, take Regex::MatchData#[] which has the following code example:
The documentation for
Regex
uses a lot ofnot_nil!
in the code examples, and is one of only 4 pages to do this, but it should not be like this. It is generally recommended to not use this method where possible (or unless absolutely necessary, IMO) and the Regex docs should reflect that.Most (if not all) of the examples are to do with the
String#match
method which is nilable, so I have created #13119 to address that, but another solution could be to recommend the conditional statement check syntax. For example, takeRegex::MatchData#[]
which has the following code example:This could easily be changed to:
I believe that this is much clearer than the existing example and it effectively avoids using
not_nil!
thanks to the conditional logic.WDYT?
The text was updated successfully, but these errors were encountered: