[ruby-core:113327] [Ruby master Feature#19559] Introduce `Symbol#+@` and `Symbol#-@`, and eventually replace boolean arguments with symbols
From:
"sawa (Tsuyoshi Sawada) via ruby-core" <ruby-core@...>
Date:
2023-04-24 17:24:00 UTC
List:
ruby-core #113327
Issue #19559 has been updated by sawa (Tsuyoshi Sawada).
Dear moderators
Please ban user austin (Austin Ziegler).
----------------------------------------
Feature #19559: Introduce `Symbol#+@` and `Symbol#-@`, and eventually replace boolean arguments with symbols
https://bugs.ruby-lang.org/issues/19559#change-102888
* Author: sawa (Tsuyoshi Sawada)
* Status: Rejected
* 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 -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/