From: "sawa (Tsuyoshi Sawada)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110315] [Ruby master Feature#17290] Syntax sugar for boolean keyword argument
Date: Sat, 15 Oct 2022 16:57:11 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-99605.20221015165710.2963@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17290.20201029025440.2963@ruby-lang.org
Issue #17290 has been updated by sawa (Tsuyoshi Sawada).
I think Marc-Andre and Brandon's idea can be limited to be relevant only for receiving the parameters (in a definition), and it will still make sense. My proposal is is about the parameters (in a method call). I think they can be kept distinct.
I rarely see people using `gets(chomp: true)`, and I think it is because it is shorter to write `gets.chomp`. It is a pity that such a useful feature was introduced, but no one uses it because the old school way is more convenient.
----------------------------------------
Feature #17290: Syntax sugar for boolean keyword argument
https://bugs.ruby-lang.org/issues/17290#change-99605
* 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/
next prev parent reply other threads:[~2022-10-15 16:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 2:54 [ruby-core:100630] [Ruby master Feature#17290] Syntax sugar for boolean keyword argument sawadatsuyoshi
2020-10-29 4:29 ` [ruby-core:100633] " marcandre-ruby-core
2020-10-29 4:51 ` [ruby-core:100634] " keystonelemur
2022-10-15 16:57 ` sawa (Tsuyoshi Sawada) [this message]
2023-03-30 5:35 ` [ruby-core:113046] " sawa (Tsuyoshi Sawada) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-99605.20221015165710.2963@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=ruby-core@neon.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).