ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Matthew Kerwin <matthew@kerwin.net.au>
To: Ruby developers <ruby-core@ruby-lang.org>
Subject: [ruby-core:81794] Re: [Ruby trunk Feature#13683] Add strict Enumerable#single
Date: Wed, 28 Jun 2017 07:41:07 +1000	[thread overview]
Message-ID: <CACweHNDQ3toCm3rgzA-zW=ZwZ8jEamVTOWxgGk81z8UFiYK7TA@mail.gmail.com> (raw)
In-Reply-To: <redmine.journal-65489.20170627200535.0c99925bc0ec2746@ruby-lang.org>


[-- Attachment #1.1: Type: text/plain, Size: 776 bytes --]

On 28 Jun. 2017 06:06, <shevegen@gmail.com> wrote:

Issue #13683 has been updated by shevegen (Robert A. Heiler).


I am not against or in favour of it but just a question.

What would the results be for the following code? In ruby (I find
it easier to read ruby code rather than the description actually):


I'm not sure the description is that hard to read... Is the same as #first
but raises an exception of the enum doesn't have exactly one element.


    [].single
    [1].single
    [1,2].single
    [1,2,3].single


Err, 1, err, err


    {}.single
    {cat: 'Tom'}.single
    {cat: 'Tom', mouse: 'Jerry'}.single


Err, ['cat', 'Tom'], err


    (And any other Enumerable objects I may have forgotten here.)


Same as .to_a.single I suppose.

Cheers
-- 
Matthew Kerwin

[-- Attachment #1.2: Type: text/html, Size: 2166 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]


Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

  reply	other threads:[~2017-06-27 21:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13683.20170627060807@ruby-lang.org>
2017-06-27  6:08 ` [ruby-core:81779] [Ruby trunk Bug#13683] Add strict Enumerable#single dnagir
2017-06-27 10:18 ` [ruby-core:81788] [Ruby trunk Feature#13683] " eregontp
2017-06-27 20:05 ` [ruby-core:81793] " shevegen
2017-06-27 21:41   ` Matthew Kerwin [this message]
2017-06-27 23:19 ` [ruby-core:81796] " mame
2017-06-28  1:15 ` [ruby-core:81798] " shannonskipper
2017-06-28  6:22 ` [ruby-core:81803] " nobu
2017-06-30 13:57 ` [ruby-core:81874] " dnagir
2017-06-30 14:01 ` [ruby-core:81875] " dnagir
2017-07-24  0:26 ` [ruby-core:82140] " johncbackus
2017-09-25  9:05 ` [ruby-core:82983] [Ruby trunk Feature#13683][Feedback] " matz
2018-04-16 22:45 ` [ruby-core:86554] [Ruby trunk Feature#13683] " me
2018-04-24 12:40 ` [ruby-core:86665] " nobu
2018-07-26 20:40 ` [ruby-core:88129] " shannonskipper
2019-04-02 16:11 ` [ruby-core:92111] " lisa.ugray
2019-10-06 20:14 ` [ruby-core:95250] [Ruby master " jonathan
2019-10-07  2:23 ` [ruby-core:95254] " daniel
2019-10-17  5:59 ` [ruby-core:95382] " matz
2019-10-17  6:24 ` [ruby-core:95384] " ppyd
2019-10-17  7:24 ` [ruby-core:95388] " hanmac
2019-10-17 17:55 ` [ruby-core:95399] " daniel
2019-11-13 16:04 ` [ruby-core:95845] " kuchenbecker.k

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='CACweHNDQ3toCm3rgzA-zW=ZwZ8jEamVTOWxgGk81z8UFiYK7TA@mail.gmail.com' \
    --to=ruby-core@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).