From: "Eregon (Benoit Daloze) via ruby-core" Date: 2024-10-10T10:48:34+00:00 Subject: [ruby-core:119504] [Ruby master Feature#20793] Allow Multiple Arguments for the .is_a? Method Issue #20793 has been updated by Eregon (Benoit Daloze). I think pattern matching can/should be used here instead of making `is_a?` more complicated: ``` irb(main):001:0> name = :abc => :abc irb(main):002:0> name in String | Symbol => true irb(main):003:0> name = 42 => 42 irb(main):004:0> name in String | Symbol => false ``` `is_a?` is deeply optimized so accepting multiple arguments would likely make it slower or complicate things significantly. ---------------------------------------- Feature #20793: Allow Multiple Arguments for the .is_a? Method https://bugs.ruby-lang.org/issues/20793#change-110119 * 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/