Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Why no mutating filter function for strings?

$
0
0

Is there a reason why

julia> str = " a"
" a"

julia> filter(isspace, str)
" "

works but

julia> filter!(isspace, str)
ERROR: MethodError: no method matching filter!(::typeof(isspace), ::String)
Closest candidates are:
  filter!(::Any, ::AbstractArray{T,1} where T) at array.jl:2503
  filter!(::Any, ::IdDict) at iddict.jl:162
  filter!(::Any, ::Dict{K,V}) where {K, V} at dict.jl:686
  ...
Stacktrace:
 [1] top-level scope at REPL[3]:1

doesn’t? Why there isn’t a mutating form of filter for strings?

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images