From: Austin Ziegler Date: 2021-04-26T13:56:14-04:00 Subject: [ruby-core:103598] Re: [Ruby master Feature#17830] Add Integer#previous and Integer#prev To be fair, the lack of a useful name for a method could also be a reason it isn���t used. I don���t think that is the case here; I don���t think that I���ve ever used Integer#succ, since it is _mostly_ only useful in cases where `count += 1` is shorter and more expressive than `count += count.succ`. -a On Mon, Apr 26, 2021 at 1:41 PM wrote: > > Issue #17830 has been updated by marcandre (Marc-Andre Lafortune). > > > I'm against this proposal. > > In general, I don't favor aliases as they usually increase cognitive load, make code less uniform and add very little. > > More importantly in this case, `Integer#pred` is not a frequently used method. Actually, I can not recall using it, or seeing it used ever. A method that isn't very useful should not have 3 different names. > > ---------------------------------------- > Feature #17830: Add Integer#previous and Integer#prev > https://bugs.ruby-lang.org/issues/17830#change-91688 > > * Author: rafasoares (Rafael Soares) > * Status: Open > * Priority: Normal > ---------------------------------------- > I think `Integer#pred` is great as the inverse of `#succ`, but it reads a bit weird as the inverse of `#next`, which might be preferable for those going for a more "reads like English" approach. > > On that note, `#previous` reads better, but it's also twice as long as `#pred` (or even `#next`). Which is why I've also added the shorthand `#prev` > > Since Ruby strives for readability, I always thought it was weird that the team omitted this improvement. > > Also, I thought about writing a gem for this, but: > 1. Do we really want to add another gem for such a simple change to every project? > 2. Monkey-patching gems feel dirty. > > Finally, I want to mention that I tried looking for previous discussions on this topic, as it seems likely someone would've brought this up at some point, but was unsuccessful. Probably due to the massive amount of baggage in the core issue tracker and mailing lists, I could've missed something among the noise. > > I've created a fork on GitHub (https://github.com/rafasoares/ruby/commit/05119848b1f480db2e809f964528799030cc7ebb) in order to open a PR, but decided to open this ticket as well, after reading the contributing guide more carefully. > > > > -- > https://bugs.ruby-lang.org/ > > Unsubscribe: > -- Austin Ziegler ��� halostatue@gmail.com ��� austin@halostatue.ca http://www.halostatue.ca/ ��� http://twitter.com/halostatue Unsubscribe: