[#49957] Re: [ruby-changes:45210] nobu:r57283 (trunk): benchmarks for [Bug #13113] [ci skip] — SASADA Koichi <ko1@...>
中田さん:
3 messages
2017/01/19
[ruby-dev:49944] [Ruby trunk Feature#13067] TrueClass, FalseClass to provide `===` to match truthy/falsy values.
From:
nobu@...
Date:
2017-01-04 07:23:02 UTC
List:
ruby-dev #49944
Issue #13067 has been updated by Nobuyoshi Nakada. Aaron Patterson wrote: > The `:itself.to_proc` doesn't look so great as an alternative, but maybe we could make `case / when` support `&:itself` syntax. `case / when` isn't the original concern, but just an unexpected side effect. Everybody can write that `foo` method, and `select(&method(:foo))` and so on, but it won't look nice. ---------------------------------------- Feature #13067: TrueClass,FalseClass to provide `===` to match truthy/falsy values. https://bugs.ruby-lang.org/issues/13067#change-62386 * Author: Yukihiro Matsumoto * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto * Target version: ---------------------------------------- I propose to make `TrueClass`, `FalseClass` to provide `===` method to match truthy values (`TrueClass`), and falsy values (`FalseClass`), so that we can use true and false for case pattern matching. And we can pick truthy values using `grep` e.g. `ary.grep(true)`. Matz. -- https://bugs.ruby-lang.org/