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
There's a bunch of overloads of #slice/#[], many of which are technically nilable, but don't return nil in practice.
We can't fix that in the general case, but of a lot uses with ranges start from 0 (or ending in -1 can be replaced by more dedicated methods like first/drop/last, which aren't nilable.
A challenge here is that the APIs aren't consistent between Array and String (and other types), and there's no way to only make the change for particular types.
These examples assume:
a=Array(0..9)s=Array("a".."z").join
Replace with first
Applicable for Array, but requires a patch from ActiveSupport for String.
Really, these likely just be s, but we can't be sure that the callers weren't relying on the result being a new copy of the string, so we'd conservatively need to dup it.
There's a bunch of overloads of
#slice
/#[]
, many of which are technically nilable, but don't returnnil
in practice.We can't fix that in the general case, but of a lot uses with ranges start from
0
(or ending in-1
can be replaced by more dedicated methods likefirst
/drop
/last
, which aren't nilable.A challenge here is that the APIs aren't consistent between
Array
andString
(and other types), and there's no way to only make the change for particular types.These examples assume:
Replace with
first
Applicable for
Array
, but requires a patch fromActiveSupport
forString
.Replace with
last
Applicable for
Array
, but not toString
.Replace with
dup
Really, these likely just be
s
, but we can't be sure that the callers weren't relying on the result being a new copy of the string, so we'd conservatively need todup
it.The text was updated successfully, but these errors were encountered: