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
By analogy to the Python idiom ary[:], I would guess that the "bad" form is often written specifically to make a copy rather than an alias.
I suggest that the advice be changed to say something like ary.clone, ary.dup or [*ary] is preferred (whatever is considered better style), or that simply ary is preferred if a copy isn't needed. If clone is a good alternative then it's worth adding that it isn't exactly synonymous with a full slice, since even ary.clone(freeze: false) clones the singleton class, whereas slicing doesn't.
The text was updated successfully, but these errors were encountered:
In the style guide under Slicing with Ranges it's said that
However, one makes a shallow copy while the other doesn't:
By analogy to the Python idiom
ary[:]
, I would guess that the "bad" form is often written specifically to make a copy rather than an alias.I suggest that the advice be changed to say something like
ary.clone
,ary.dup
or[*ary]
is preferred (whatever is considered better style), or that simplyary
is preferred if a copy isn't needed. Ifclone
is a good alternative then it's worth adding that it isn't exactly synonymous with a full slice, since evenary.clone(freeze: false)
clones the singleton class, whereas slicing doesn't.The text was updated successfully, but these errors were encountered: