ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: fukajun.shark@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92540] [Ruby trunk Feature#15824] respond_to pattern for pattern match
Date: Sun, 05 May 2019 00:00:45 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-15824.20190505000045.077946e6effc88e2@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15824.20190505000045@ruby-lang.org

Issue #15824 has been reported by fukajun (Jun Fukaya).

----------------------------------------
Feature #15824: respond_to pattern for pattern match
https://bugs.ruby-lang.org/issues/15824

* 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/

       reply	other threads:[~2019-05-05  0:00 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 ` fukajun.shark [this message]
2019-05-05 15:32 ` [ruby-core:92552] [Ruby trunk Feature#15824] respond_to pattern for pattern match shevegen
2019-05-22  8:57 ` [ruby-core:92777] " matz
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.issue-15824.20190505000045.077946e6effc88e2@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).