From: keystonelemur@... Date: 2020-10-29T04:51:37+00:00 Subject: [ruby-core:100634] [Ruby master Feature#17290] Syntax sugar for boolean keyword argument Issue #17290 has been updated by baweaver (Brandon Weaver). I would concur with Marc-Andre on this one, I believe punning would be a more valuable feature, especially for keyword arguments. Examples: ```ruby def method_name(foo: 1, bar: 2, baz: 3) foo + bar + baz end foo = 1 bar = 2 baz = 3 method_name(foo:, bar:, baz:) # 1, 2, 3 # => 6 # Also punning in hashes which would be distinct from block syntax: { foo:, bar:, baz: } # => { foo: 1, bar: 2, baz: 3 } ``` May open a separate ticket on those ideas or amend a current punning proposition ---------------------------------------- Feature #17290: Syntax sugar for boolean keyword argument https://bugs.ruby-lang.org/issues/17290#change-88269 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal ---------------------------------------- We frequently use keyword arguments just to pass `true` value out of the truthy/falsy options given. And in many such cases, the falsy option is set as the default, and only the truthy value is ever passed explicitly. I propose to have a syntax sugar to omit the value of a keyword argument. When omitted, it should be interpreted with value `true`. ```ruby gets(chomp:) CSV.parse(" foo var ", strip:) ``` should be equivalent to ```ruby gets(chomp: true) CSV.parse(" foo var ", strip: true) ``` Additionally, we may also extend this to pragmas. ```ruby # frozen_string_literal: ``` to be equivalent to: ```ruby # frozen_string_literal: true ``` -- https://bugs.ruby-lang.org/ Unsubscribe: