-
-
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
define keys on RegexMatch #37299
define keys on RegexMatch #37299
Conversation
3. in consistent with
|
Is it really simpler than e.g. a |
No it isn't. |
I guess the advantage is that with a |
This is a good feature, but I definitely think it should not return a tuple. A Vector would be fine. The tuple version is type-unstable, and I doubt you would ever want code specialized on this. |
Please fix test and rebase. |
f418795
to
7b5f3d2
Compare
754f245
to
b64596e
Compare
I thought this was merged ages ago. |
Bump |
add to News.md about defining keys on RegexMatch fix whitespace return a Vector from keys(::RegexMatch) correct test of RegexMatch keys regex keys displayed are strings (since that is how we get them from PCRE)
b64596e
to
0fd02fb
Compare
Bump. |
This came up in discussion in #34355
Seperating it out from that PR because it is a far less clear question/answer.
In general if we define
getindex
we should definekeys
.Some things in this PR you might take issue with:
### 1. It returns a tuple. `keys` only promises that it will return a iterator. `keys` on a `NamedTuple` returns a `Tuple`, `keys` on a `Vector` returns a `OneTo`. A `Tuple` just seems like the simplest thing to do this will normally be small so i didn't think some kind of `KeySet` would be appropriate also the keys *are* infact ordered, just like the are for a `NamedTuple`.2. It returns a mix of named and number keys.
We can't return all named since they might not all be named.
We could return all numbered, I would be down with that.
Very easy PR.
keys(m::RegexMatch = keys(m.captures)
.It seems like this is what we want since this is what
show
currently displays.