From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_PASS,T_DKIM_INVALID shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 59ECE20401 for ; Tue, 27 Jun 2017 21:41:24 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id ABD4412080E; Wed, 28 Jun 2017 06:41:15 +0900 (JST) Received: from mail-it0-f42.google.com (mail-it0-f42.google.com [209.85.214.42]) by neon.ruby-lang.org (Postfix) with ESMTPS id 934CD1207F6 for ; Wed, 28 Jun 2017 06:41:10 +0900 (JST) Received: by mail-it0-f42.google.com with SMTP id b205so23453002itg.1 for ; Tue, 27 Jun 2017 14:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=Jlc5k1a6aCwnO1aSPsWGjkkyaoPpc1mqDlxf0uuSbmM=; b=SqKXMAKIha+gb1xIo/mWxHxkZrN4W/SRG1y2zHZDCxIjR8XMHTDGxYbL3CZ/YPn+sa AwDrwb8eFtcc5hCKYfhJt9/pS1HW6nsm/i7ulHPVgqdXeiASOMVKKAcjt1fq+t/9goz1 2Fx5Lqls+gcoa6Qz8kV+1YEheJmEYAwg7s2/nPhTNaWdqKoQdElRK6U+StGervl/28WI AHjHsOhHGSPcw63xHMcyolxTsTl82EYcQkfrLG7aGdpXSoqIin8Do93uYVX7sNS6w7qu S7KtTZAs2IVuMBABi2wiubp/cdPktf7qMX0QsOdEJp0eysgpA6HuA7UERqthgKnrv+0S gcVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=Jlc5k1a6aCwnO1aSPsWGjkkyaoPpc1mqDlxf0uuSbmM=; b=sWOIaz9AyQNhkpM1pRepf0z1bk6ryerxbtFgtXXh1IR+kC5lbX+awjM3wLVPmL/CLJ ikpWPaco1voe3nNe+oZKJajlvpO9XBkq6qmeEzrDkBu6yjolRXDk4oD/1K+aybFsVHsr WaH9wfEFP1+SufAVLqIhQaYvncyn++fZIeRIwZAQH9bpDBn4sKiFKrYwNVxbL4TyYXqw oLiRgEhW6Exi+YCtev/zh0lcDRjpRy6dgKuryK7Zqtj7arpkDaXB6+xJS/DGnUUpzusb P4RARVsPBSD3zhw8AKvycUW1sXaDG9rLTrexTQ5KbKud0khSXuv4wUtwI4LzVbGe6YVr W7Zg== X-Gm-Message-State: AKS2vOygIjC3vIHbfT9CMXuIpki2zZOzfHQy0qJo4UaCqkJuQ0Nrzaig qAt+E2DjZ51M8DR2IcfCsKBhUkmbo3LS X-Received: by 10.36.98.206 with SMTP id d197mr5314564itc.50.1498599667934; Tue, 27 Jun 2017 14:41:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.20.13 with HTTP; Tue, 27 Jun 2017 14:41:07 -0700 (PDT) Received: by 10.107.20.13 with HTTP; Tue, 27 Jun 2017 14:41:07 -0700 (PDT) In-Reply-To: References: From: Matthew Kerwin Date: Wed, 28 Jun 2017 07:41:07 +1000 X-Google-Sender-Auth: NX4CiQlFiWAskhHtDCe1upMCEV8 Message-ID: To: Ruby developers X-ML-Name: ruby-core X-Mail-Count: 81794 Subject: [ruby-core:81794] Re: [Ruby trunk Feature#13683] Add strict Enumerable#single X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1283220174==" Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" --===============1283220174== Content-Type: multipart/alternative; boundary="001a1144503ede6b4c0552f7ecd9" --001a1144503ede6b4c0552f7ecd9 Content-Type: text/plain; charset="UTF-8" On 28 Jun. 2017 06:06, 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 --001a1144503ede6b4c0552f7ecd9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


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&#= 39;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.<= /div>


=C2=A0 =C2=A0 [].single
=C2=A0 =C2=A0 [1].single
=C2=A0 =C2=A0 [1,2].single
=C2=A0 =C2=A0 [1,2,3].single

Err, 1, err, err
<= br>

=C2=A0 =C2=A0 {}.single
=C2=A0 =C2=A0 {cat: 'Tom'}.single
=C2=A0 =C2=A0 {cat: 'Tom', mouse: 'Jerry'}.single

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


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

Same as .to_a.single I suppose.

Cheers
--= =C2=A0
Matthew Kerwin=C2=A0
--001a1144503ede6b4c0552f7ecd9-- --===============1283220174== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Unsubscribe: --===============1283220174==--