Issue #7986 has been updated by trans (Thomas Sawyer).


=begin
> "It is puzzling that you must always super first, then if unhandled execute the case expression, but do nothing if the object is unknown. It seems very error prone."

Why? That's not uncommon. In this particular case you don't "always". It depends on which you want to take precedence, the superclass or the subclass. Recall my case is in place of a DSL --it's up to the end developer to decide which. Super may even be called in the middle somewhere. It is not at all error prone in the least.

> A case expression can already handle URI matching just fine

Of course, and I mentioned that. And what did I say? Quote: "think of the efficiency improvements over the typical use of regular expressions". Moreover the point has nothing whatsoever to do with URIs.

I could sit here and give 100 different examples and for everyone, someone could say, well you could also do it this way. In the end you can replace every case statement with if/else too. That point is the convenience it provides.
=end

----------------------------------------
Feature #7986: Custom case statement comparison method
https://bugs.ruby-lang.org/issues/7986#change-37244

Author: trans (Thomas Sawyer)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: Next Major


=begin
Case statements use #=== to handle matching, but sometimes this can be limiting. It such cases it would be helpful to be able to specify the comparison method. So I wondered if that could be done by hanging the method off the `case` keyword, e.g.

    class Bar < Foo; end

    case == obj.class
    when Foo
      p "Foo, not Bar!"
    when Bar
      p "Bar!"
    end

And

    case.include? name
    when a
      p "a includes name"
    when b
      p "b includes name, not a"
    else
      p "neither a or b includes name"
    end
=end



-- 
http://bugs.ruby-lang.org/