From: matz@ruby.or.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92777] [Ruby trunk Feature#15824] respond_to pattern for pattern match
Date: Wed, 22 May 2019 08:57:51 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-78142.20190522085751.4d5f7bf2b5ffa32b@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15824.20190505000045@ruby-lang.org
Issue #15824 has been updated by matz (Yukihiro Matsumoto).
Interesting idea. We need to investigate the idea further.
Matz.
----------------------------------------
Feature #15824: respond_to pattern for pattern match
https://bugs.ruby-lang.org/issues/15824#change-78142
* Author: fukajun (Jun Fukaya)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
rubyに追加されそうなパターンマッチの機能について...
Interger, Array など constantを書くことで、オブジェクトのクラスにマッチングさせる機能があるのを拝見しました。
duck typingを確認するようなパターンマッチがかけるとrubyらしいのではないかと思ってこちらに書いてみることにしました。
respond_to pattern
```ruby
class Runner
def run
end
def stop
end
end
runner = Runner.new
case runner
in .run & .stop
:reachable
in .start & .stop
:unreachable
end
```
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-05-22 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15824.20190505000045@ruby-lang.org>
2019-05-05 0:00 ` [ruby-core:92540] [Ruby trunk Feature#15824] respond_to pattern for pattern match fukajun.shark
2019-05-05 15:32 ` [ruby-core:92552] " shevegen
2019-05-22 8:57 ` matz [this message]
2019-10-06 7:56 ` [ruby-core:95243] [Ruby master " s.wanabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-78142.20190522085751.4d5f7bf2b5ffa32b@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).