From: "vo.x (Vit Ondruch) via ruby-core" Date: 2023-03-31T07:19:28+00:00 Subject: [ruby-core:113058] [Ruby master Feature#19559] Introduce `Symbol#+@` and `Symbol#-@`, and eventually replace boolean arguments with symbols Issue #19559 has been updated by vo.x (Vit Ondruch). One of the benefits or Ruby used to be readability. There were great times when `Integer("2.3", :exception => false)` was standard. Than came the JS hash notation `Integer("2.3", exception: false)` which have not improved the situation and now this `Integer("2.3", -:exception)`? IOW I am against this proposal, because it will make the code less readable. ---------------------------------------- Feature #19559: Introduce `Symbol#+@` and `Symbol#-@`, and eventually replace boolean arguments with symbols https://bugs.ruby-lang.org/issues/19559#change-102596 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal ---------------------------------------- I propose to define `Symbol#+@` and `Symbol#-@`, so that we can add positive or negative polarity to symbols. A possible implementation can be equivalent to what can be achieved by this: ```ruby class Symbol def -@; "-#{self}".to_sym end def +@; self end end ``` The intention behind this is to, eventually, replace boolean positional or keyword arguments with symbols so that, instead of this: ```ruby "foo".methods(false) gets(chomp: true) Integer("2.3", exception: false) ``` we can write like this: ```ruby "foo".methods(-:inherit) gets(+:chomp) Integer("2.3", -:exception) ``` -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/