Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip does not take predicate functions. #31195

Closed
sbromberger opened this issue Feb 28, 2019 · 1 comment
Closed

strip does not take predicate functions. #31195

sbromberger opened this issue Feb 28, 2019 · 1 comment
Labels
docs This change adds or pertains to documentation strings "Strings!"

Comments

@sbromberger
Copy link
Contributor

sbromberger commented Feb 28, 2019

From strip's docstring (emphasis mine):

The optional chars argument specifies which characters to remove: it can be a single character, vector or set of characters, or a predicate function.

However:

julia> a = "hello!"
"hello!"

julia> strip(a, ispunct)
ERROR: MethodError: no method matching rstrip(::String, ::typeof(ispunct))

(note the error is in rstrip, not strip.)

julia> methods(strip)
# 2 methods for generic function "strip":
[1] strip(s::AbstractString) in Base at strings/util.jl:214
[2] strip(s::AbstractString, chars) in Base at strings/util.jl:215

julia> methods(rstrip)
# 3 methods for generic function "rstrip":
[1] rstrip(s::AbstractString) in Base at strings/util.jl:194
[2] rstrip(f, s::AbstractString) in Base at strings/util.jl:189
[3] rstrip(s::AbstractString, chars::Union{AbstractChar, Tuple{Vararg{AbstractChar,N} where N}, Set{#s55} where #s55<:AbstractChar, AbstractArray{#s56,1} where #s56<:AbstractChar}) in Base at strings/util.jl:195
julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.2.0)
  CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

Edited to add: even if you put the predicate function first, strip doesn't work.

@ararslan
Copy link
Member

Looks like lstrip and rstrip got methods with a predicate function (as the first argument, per convention), but strip was omitted. Should be non-breaking to add such a method, so we could do it in 1.x, but in the meantime we should fix the 1.0 docs to not suggest that such a method exists for strip.

ararslan added a commit that referenced this issue Feb 28, 2019
`lstrip` and `rstrip` take a predicate function as the first argument.
It seems `strip` did not receive that addition, though its docstring
suggests that it did.

See #31195.
ararslan added a commit that referenced this issue Feb 28, 2019
`strip` is documented to accept a function argument but it does not.
`rstrip` and `lstrip` do, so it seems this was simply an oversight.

See #31195.
ararslan added a commit that referenced this issue Feb 28, 2019
`lstrip` and `rstrip` take a predicate function as the first argument.
It seems `strip` did not receive that addition, though its docstring
suggests that it did.

See #31195.
ararslan added a commit that referenced this issue Mar 1, 2019
`strip` is documented to accept a function argument but it does not.
`rstrip` and `lstrip` do, so it seems this was simply an oversight.

See #31195.
@kshyatt kshyatt added docs This change adds or pertains to documentation strings "Strings!" labels Mar 1, 2019
StefanKarpinski pushed a commit that referenced this issue Mar 3, 2019
`lstrip` and `rstrip` take a predicate function as the first argument.
It seems `strip` did not receive that addition, though its docstring
suggests that it did.

See #31195.
ararslan added a commit that referenced this issue Mar 3, 2019
`strip` is documented to accept a function argument but it does not.
`rstrip` and `lstrip` do, so it seems this was simply an oversight.

See #31195.
fredrikekre pushed a commit that referenced this issue Mar 4, 2019
`strip` is documented to accept a function argument but it does not.
`rstrip` and `lstrip` do, so it seems this was simply an oversight.

See #31195.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation strings "Strings!"
Projects
None yet
Development

No branches or pull requests

3 participants