Project

General

Profile

Actions

Feature #19559

closed

Introduce `Symbol#+@` and `Symbol#-@`, and eventually replace boolean arguments with symbols

Added by sawa (Tsuyoshi Sawada) over 1 year ago. Updated over 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:113045]

Description

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:

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:

"foo".methods(false)

gets(chomp: true)

Integer("2.3", exception: false)

we can write like this:

"foo".methods(-:inherit)

gets(+:chomp)

Integer("2.3", -:exception)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like1Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0