From: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:51191] [Ruby master Bug#18953] `Array#uniq` doesn't evaluate the given block when the size of the array is one
Date: Wed, 03 Aug 2022 06:12:49 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-98571.20220803061248.12651@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-18953.20220802021548.12651@ruby-lang.org>
Issue #18953 has been updated by nobu (Nobuyoshi Nakada).
I think this is an expected behavior, but an implementation detail.
----------------------------------------
Bug #18953: `Array#uniq` doesn't evaluate the given block when the size of the array is one
https://bugs.ruby-lang.org/issues/18953#change-98571
* Author: ttanimichi (Tsukuru Tanimichi)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`Array#uniq` doesn't evaluate the given block when the size of the array is one. Is this expected behavior?
```
$ ruby -e '[42, 43].uniq { _1.foo }; puts true'
-e:1:in `block in <main>': undefined method `foo' for 42:Integer (NoMethodError)
[42, 43].uniq { _1.foo }; puts true
^^^^
Did you mean? floor
from -e:1:in `uniq'
from -e:1:in `<main>'
```
```
$ ruby -e '[42].uniq { _1.foo }; puts true'
true
```
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2022-08-03 6:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 2:15 [ruby-dev:51189] " ttanimichi (Tsukuru Tanimichi)
2022-08-03 4:52 ` [ruby-dev:51190] " mrkn (Kenta Murata)
2022-08-03 6:12 ` nobu (Nobuyoshi Nakada) [this message]
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-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-98571.20220803061248.12651@ruby-lang.org \
--to=noreply@ruby-lang.org \
--cc=ruby-dev@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 NNTP newsgroup(s).