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 current trimmingPrefx drops the information about whether the prefix was matched. I often do something like:
if x.starts(with:"foo"){doSomething(with: x.dropFirst("foo".count))}
Proposed solution
iflet y = x.trimmingPrefixOrNil("foo"){doSomething(with: y)}
Would be more expressive, less error prone, and more efficient. I don't love the name; maybe something better can be found. Frankly I think trimmingPrefix would have been a better name for the functionality I want. After all if "foo" can't be trimmed off the front of x, then x with the prefix "foo" trimmed is not a thing, and nil is an appropriate response.
Alternatives considered
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
Motivation
The current
trimmingPrefx
drops the information about whether the prefix was matched. I often do something like:Proposed solution
Would be more expressive, less error prone, and more efficient. I don't love the name; maybe something better can be found. Frankly I think
trimmingPrefix
would have been a better name for the functionality I want. After all if "foo" can't be trimmed off the front ofx
, thenx
with the prefix "foo" trimmed is not a thing, andnil
is an appropriate response.Alternatives considered
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: