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
Is there some reason why @view and @views don't produce SubString objects?
julia> s = "αβγ"
"αβγ"
julia> s[3:5] # a copy
"βγ"
julia> @view s[3:5]
ERROR: MethodError: no method matching view(::String, ::UnitRange{Int64})
Closest candidates are:
view(::AbstractUnitRange, ::AbstractUnitRange{var"#s91"} where var"#s91"<:Integer) at subarray.jl:167
view(::StepRange, ::AbstractRange{var"#s91"} where var"#s91"<:Integer) at subarray.jl:175
view(::StepRangeLen, ::OrdinalRange{var"#s91",S} where S where var"#s91"<:Integer) at subarray.jl:179
...
Stacktrace:
[1] top-level scope at REPL[25]:1
julia> SubString(s, 3:5) # I wish this was @view s[3:5]
"βγ"
julia> @views s[3:5] # actually returns a copy
"βγ"
julia> typeof(ans)
String
Fixing @view would be a non-breaking change since it currently throws an error. Fixing @views would technically be breaking but I'm skeptical that it affects any real code?
The text was updated successfully, but these errors were encountered:
Is there some reason why
@view
and@views
don't produceSubString
objects?Fixing
@view
would be a non-breaking change since it currently throws an error. Fixing@views
would technically be breaking but I'm skeptical that it affects any real code?The text was updated successfully, but these errors were encountered: