From: shevegen@... Date: 2020-03-01T20:38:57+00:00 Subject: [ruby-core:97322] [Ruby master Feature#16666] 'string' - 'str' as a shortcut for 'string'.gsub('str', '')? Issue #16666 has been updated by shevegen (Robert A. Heiler). > Does anyone else think the same syntax would be beneficial for Strings? I do not doubt that it can be useful. One advantage of your proposal is that it is very short and succinct. Personally, though, I prefer .gsub() or .gsub!(), and .delete or sawa's suggestion. I don't have anything against "-" per se and as you showed that Array has the method, the same could perhaps be used for class String. But this may be a design decision (I don't know). But perhaps there is a design consideration matz considered (or not, I really do not know). It may be best to ask matz about - for class String. I would also recommend to contrast your proposal to what sawa suggested; for example, you could propose - to be an alias of String#delete, or something else. That may be helpful or perhaps simpler. (I myself really don't know) ---------------------------------------- Feature #16666: 'string' - 'str' as a shortcut for 'string'.gsub('str', '')? https://bugs.ruby-lang.org/issues/16666#change-84445 * Author: vladpisanov (Vlad Pisanov) * Status: Open * Priority: Normal ---------------------------------------- Sorry if this has been brought up before, but I couldn't find anything. I love how we can substract arrays (`[1,2,3] - [1,2]`). Does anyone else think the same syntax would be beneficial for Strings? Some possible scenarios could be: ```ruby 'string' - 'str' # Remove substring 'string' - ['s', 't'] # Remove a set of characters 'string' - /^st/ # Remove by regexp ``` -- https://bugs.ruby-lang.org/ Unsubscribe: