ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "artemb (Artem Borodkin) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "artemb (Artem Borodkin)" <noreply@ruby-lang.org>
Subject: [ruby-core:119505] [Ruby master Feature#20793] Allow Multiple Arguments for the .is_a? Method
Date: Thu, 10 Oct 2024 11:21:51 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-110120.20241010112150.53214@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20793.20241010085019.53214@ruby-lang.org>

Issue #20793 has been updated by artemb (Artem Borodkin).


Eregon (Benoit Daloze) wrote in #note-2:
> I think pattern matching should be used here instead 
Very nice, thank you!

If kind_of? (and alias is_a?) has a strong implementation optimization, I agree that this is not so important enhancement.

----------------------------------------
Feature #20793: Allow Multiple Arguments for the .is_a? Method
https://bugs.ruby-lang.org/issues/20793#change-110120

* Author: artemb (Artem Borodkin)
* Status: Open
----------------------------------------
I propose allowing multiple arguments to be passed to the .is_a? Method imply "OR" semantics:


``` ruby
name.is_a? String, Symbol
```

Currently, we need to write the following to achieve the same functionality:

``` ruby
[String, Symbol].include?(name.class)
```






-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

  parent reply	other threads:[~2024-10-10 11:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10  8:50 [ruby-core:119502] " artemb (Artem Borodkin) via ruby-core
2024-10-10  9:55 ` [ruby-core:119503] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-10 10:48 ` [ruby-core:119504] " Eregon (Benoit Daloze) via ruby-core
2024-10-10 11:21 ` artemb (Artem Borodkin) via ruby-core [this message]
2024-11-07  8:58 ` [ruby-core:119794] " matz (Yukihiro Matsumoto) via ruby-core

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-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-110120.20241010112150.53214@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@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 NNTP newsgroup(s).