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
This would be a non-nilable version of String#match. A lot of the standard library has methods for something that can error and something that should return nil instead, for example, the #[] and #[]? convention which is used throughout the standard library. This method does not, and requires doing one of the following for usage:
match ="Crystal".match(/(cr)/i).not_nil![1]
"Crystal".match(/(cr)/i)
match =$1
While you could use $1 to get around this, it becomes a pain to manage when you have a large number of capture groups or a recursive capture group, and it's not easy to identify which $ variable represents what capture. Ideally, String#match? would be preferable here, but String#match can return nil and to change that to non-nilable would be a breaking change. It's a slight inconsistency, but it's better than nothing.
The text was updated successfully, but these errors were encountered:
This would be a non-nilable version of
String#match
. A lot of the standard library has methods for something that can error and something that should returnnil
instead, for example, the#[]
and#[]?
convention which is used throughout the standard library. This method does not, and requires doing one of the following for usage:While you could use
$1
to get around this, it becomes a pain to manage when you have a large number of capture groups or a recursive capture group, and it's not easy to identify which$
variable represents what capture. Ideally,String#match?
would be preferable here, butString#match
can returnnil
and to change that to non-nilable would be a breaking change. It's a slight inconsistency, but it's better than nothing.The text was updated successfully, but these errors were encountered: