-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
figure what to do about find("string") #16269
Comments
The second point is actually a possible solution: just remove that test, and have |
In that case, why are strings the only iterable that we don't allow calling |
I understood that it would fail only because a char won't be comparable to 0 (and |
Currently, it's a deprecation warning, not an error. |
A more explicit failure could be to compare an element |
@rfourquet We discussed that at #16024 already. |
@StefanKarpinski It's a deprecation warning, and previously it didn't work at all. So nobody should use it, and when it will be removed we will be fine. Everything is perfectly consistent here, and so far nobody has expressed the need for |
@nalimilan yes precisely, so that would be another way to rule out |
My issue is that given the current definition of |
Because |
There's that problem, but I think the bigger trouble is that julia> s = "αω"
idxs = find(s)
s[idxs[end]]
ERROR: UnicodeError: invalid character index |
Just thinking aloud here, but why is |
Also, maybe it's just me, but I find this incredibly bizarre: julia> find(Any["0", :(0), 0.0, 0, false, '\0'])
1-element Array{Int64,1}:
1 |
An option would be to change the definition of function Base.find(s::String)
i = 0
v = Int64[]
while length(v) < length(s)
j = nextind(s, i)
push!(v, j)
i = j
end
v
end |
@mbauman @pabloferz Yeah, it could be more useful to go over indices and return these, with a fallback to linear indices. This would be in line with the functions @timholy is working on. This is related to the question of whether to return a @ararslan That wouldn't be bizarre if you got an error for |
Actually, as @rfourquet mentioned, comparing against |
@nalimilan Granted, Regardless, I would be in favor of restricting |
Hm. Using |
Happily, subsumed by #23120. |
See #16110 (diff). Summary, after merging #16110, we have
find("abc") == 1:3
. This has some issues. First, it finds the non-NUL indices of characters in the string argument, which is a weird and probably bad operation. Second, it conflicts with #16024, which I want to merge.The text was updated successfully, but these errors were encountered: