[ruby-dev:50873] [Ruby master Feature#16348] Proposal: Symbol#start_with?, Symbol#end_with?, and Symbol#include?

From: naruse@...
Date: 2019-11-28 16:30:31 UTC
List: ruby-dev #50873
Issue #16348 has been updated by naruse (Yui NARUSE).


duerst (Martin Dst) wrote:
> I personally think that we should be restrictive in adding new methods to `Symbol`. Otherwise, this very quickly becomes a slippery slope, and the distinction between `Symbol` and `String` becomes less and less clear.
> 
> I was personally surprised when I implemented feature #10085 that `Symbol` had `#upcase` and friends, I wouldn't have guessed that.

As far as I remember, once Matz tried and gave up to unify String and Symbol, he said Symbol should have similar set of methods while people needed.
After a decade some but small number of methods are added even if including this.
I think there's no worry.

----------------------------------------
Feature #16348: Proposal: Symbol#start_with?, Symbol#end_with?, and Symbol#include?
https://bugs.ruby-lang.org/issues/16348#change-82866

* Author: kamipo (Ryuta Kamizono)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
When replacing #match? to #start_with?, #end_with?, and #include? for some reason (address to https://bugs.ruby-lang.org/issues/13083 etc), we frequently hit missing Symbol#start_with?, Symbol#end_with?, and Symbol#include? in spite of Symbol#match? exists.

https://github.com/rails/rails/commit/63256bc5d7dd77b2cce82df46c53249dab2dc2a8
https://github.com/rails/rails/commit/a8e812964d711fa03843e76ae50f5ff81cdc9e00

Is this inconsistency intentional?
If not so, Symbol#start_with?, Symbol#end_with?, and Symbol#include? prevents such like an issue.



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

In This Thread

Prev Next