Project

General

Profile

Actions

Feature #19559

closed

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

Added by sawa (Tsuyoshi Sawada) about 1 year ago. Updated 12 months 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