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
It's using the naming convention of a mutating func. Since it isn't one , it should probably be removing(_ string: String?) to make it clear its a non-mutating-returning func. (But see 3)
There are already several other mutating funcs in String named remove or removeXXX so this one's differing semantics is confusing.
It's not immediately clear from the call site what it's doing. Since its just a wrapper on replacingOccurrences(of:) maybe a clearer name would be removingOccurences(of:)
Also, not keen on it accepting an optional string. None of the normal string manipulation funcs in stdLib behave that way and none of its existing call sites can ever pass in a nil parameter anyway.
Thanks @gutley, yeah those points totally make sense. I moved this extension from the Shared target into BrowserKit on PR #12718. If you wish to make changes to improve the naming, I'll gladly review the PR. Thank you!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Because:
removing(_ string: String?)to make it clear its a non-mutating-returning func. (But see 3)removeorremoveXXXso this one's differing semantics is confusing.replacingOccurrences(of:)maybe a clearer name would beremovingOccurences(of:)Also, not keen on it accepting an optional string. None of the normal string manipulation funcs in stdLib behave that way and none of its existing call sites can ever pass in a nil parameter anyway.
I did say it was pedantic 😀
All reactions