[#116016] [Ruby master Bug#20150] Memory leak in grapheme clusters — "peterzhu2118 (Peter Zhu) via ruby-core" <ruby-core@...>
Issue #20150 has been reported by peterzhu2118 (Peter Zhu).
7 messages
2024/01/04
[#116382] [Ruby master Feature#20205] Enable `frozen_string_literal` by default — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Issue #20205 has been reported by byroot (Jean Boussier).
77 messages
2024/01/23
[ruby-core:116105] [Ruby master Feature#16137] Add === to UnboundMethod
From:
"okuramasafumi (Masafumi OKURA) via ruby-core" <ruby-core@...>
Date:
2024-01-09 09:18:44 UTC
List:
ruby-core #116105
Issue #16137 has been updated by okuramasafumi (Masafumi OKURA).
Now that we have had pattern match for a while, I agree with Eregon, we can utilize it more rather than adding new methods.
I cannot change its status so I hope someone will do so instead of me.
----------------------------------------
Feature #16137: Add === to UnboundMethod
https://bugs.ruby-lang.org/issues/16137#change-106100
* Author: okuramasafumi (Masafumi OKURA)
* Status: Open
* Priority: Normal
----------------------------------------
# Abstract
`UnboundMethod` class should have `=== ` so that it can be used in case statement.
# Background
`Method` class has `===` method so that we can do something like:
``` ruby
require 'prime'
case 11
when Prime.method(:prime?) then :prime
end
```
However, we cannot do something like this:
```ruby
positive = Integer.instance_method(:positive?)
case 11
when positive then :positive
end
```
# Proposal
Add `===` method to `UnboundMethod` class.
# Implementation
Minimal implementation in Ruby could be:
```ruby
class UnboundMethod
def ===(other)
bind(other).call
end
end
```
# Summary
`===` for `UnboundMethod` can improve readability in case statement.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/