[#90865] [Ruby trunk Bug#15499] Breaking behavior on ruby 2.6: rb_thread_call_without_gvl doesn't invoke unblock_function when used on the main thread — apolcyn@...
Issue #15499 has been reported by apolcyn (alex polcyn).
3 messages
2019/01/03
[#90877] [Ruby trunk Bug#15499] Breaking behavior on ruby 2.6: rb_thread_call_without_gvl doesn't invoke unblock_function when used on the main thread — apolcyn@...
Issue #15499 has been updated by apolcyn (alex polcyn).
3 messages
2019/01/03
[#90895] Re: [ruby-alerts:11680] failure alert on trunk-mjit@silicon-docker (NG (r66707)) — Eric Wong <normalperson@...>
ko1c-failure@atdot.net wrote:
4 messages
2019/01/05
[#90896] Re: [ruby-alerts:11680] failure alert on trunk-mjit@silicon-docker (NG (r66707))
— Takashi Kokubun <takashikkbn@...>
2019/01/05
Thanks to explain that.
[#91200] [Ruby trunk Feature#15553] Addrinfo.getaddrinfo supports timeout — glass.saga@...
Issue #15553 has been reported by Glass_saga (Masaki Matsushita).
4 messages
2019/01/21
[#91289] Re: [Ruby trunk Feature#15553] Addrinfo.getaddrinfo supports timeout
— Eric Wong <normalperson@...>
2019/01/26
glass.saga@gmail.com wrote:
[ruby-core:90985] [Ruby trunk Feature#14444] MatchData: alias for #[]
From:
zverok.offline@...
Date:
2019-01-10 10:15:01 UTC
List:
ruby-core #90985
Issue #14444 has been updated by zverok (Victor Shepelev).
Ugh. I feel ashamed, honestly :)
Never thought about using `.slice` this way, somehow! It is definitely cleaner.
Can be closed.
----------------------------------------
Feature #14444: MatchData: alias for #[]
https://bugs.ruby-lang.org/issues/14444#change-76206
* Author: zverok (Victor Shepelev)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
After introduction of safe navigation operator and other latest features, it could be pretty idiomatic to do this:
```ruby
next_page = response.dig('meta', 'pagination', 'next')&.match(/&page=(\d+)/)&.[](1)
```
The ugly thing here is, obviously, `&.[](1)`. When dealing with other classes we can use `dig(one_key)` or `at(index)` for arrays, but for `MatchData` there are no good synonym/alias.
Two options come to mind:
* `&.capture(1)` — singular from "captures"
* `&.at(1)` — like it is in Array, from which MatchData already borrows `values_at`
Yes, several `&.` in a row could be said a code smell and example may feel a bit extreme.
But for simple matches, the principle stays the same: "match something and extract if matched" otherwise should be written in much less readable code like this:
```ruby
if url =~ /&page=(\d+)/
next_page = Regexp.last_match[1]
end
# or
if (m = url.match(/&page=(\d+)/))
next_page = m[1]
end
# this seems the most reasonable syntax anyways:
next_page = url.match(/&page=(\d+)/)&.at(1)
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>