Return-Path: X-Original-To: apmail-groovy-dev-archive@minotaur.apache.org Delivered-To: apmail-groovy-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8488C17223 for ; Fri, 22 May 2015 14:14:24 +0000 (UTC) Received: (qmail 36017 invoked by uid 500); 22 May 2015 14:14:19 -0000 Delivered-To: apmail-groovy-dev-archive@groovy.apache.org Received: (qmail 35978 invoked by uid 500); 22 May 2015 14:14:19 -0000 Mailing-List: contact dev-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.incubator.apache.org Delivered-To: mailing list dev@groovy.incubator.apache.org Received: (qmail 35964 invoked by uid 99); 22 May 2015 14:14:19 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 May 2015 14:14:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C56C1C68C6 for ; Fri, 22 May 2015 14:14:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.08 X-Spam-Level: **** X-Spam-Status: No, score=4.08 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, KAM_COUK=1.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id XrWgjLFQFY0V for ; Fri, 22 May 2015 14:14:17 +0000 (UTC) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 6ECC322F84 for ; Fri, 22 May 2015 14:14:17 +0000 (UTC) Received: by wicmx19 with SMTP id mx19so41639737wic.0 for ; Fri, 22 May 2015 07:13:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:from:date:message-id:subject:to:content-type; bh=nd5Nza/uFSYXSQkxn3RmSJuIWdVfWdF0r7lsLicbGj8=; b=iz4FSYzgGszjcym5JgQ7pJYVQbXkuyy26zEVu+JDmMkD9zNC99OrUKg5ZSgD0vFH0t p68xQNLrU1rjlNUDRv+a7aNuBRNYQPniHJctfbVyT1lwueMdLwMwsfqTX84uvTUvcSpx ktJHQChF4U1Vs/QF9RjrbsFL9lZ6t75nTOxAKjz7DjX46AgUp/JITJRLi59XwIRThUZN 09ysr+Y1ixJp8PpCMDx2JrorLTp5MRWZHGXFcBFNeu3CuTe41yx4+uuzVbVGq6cXjkYn KR2xCiJDkRsp04SKbqOCzbSWp+8RFYnSiKcSXlWdIBxyGe7LarHs+mBN+1lIM0YUCOAS zsnw== X-Received: by 10.194.189.228 with SMTP id gl4mr15767434wjc.1.1432304005135; Fri, 22 May 2015 07:13:25 -0700 (PDT) MIME-Version: 1.0 From: Peter Ledbrook Date: Fri, 22 May 2015 14:13:24 +0000 Message-ID: Subject: CharSequence.count(Closure) To: dev@groovy.incubator.apache.org Content-Type: multipart/alternative; boundary=047d7bf0bfcc6fc6910516ac4358 --047d7bf0bfcc6fc6910516ac4358 Content-Type: text/plain; charset=UTF-8 Hi, One of the things I really like about Groovy is how strings can be treated as sequences of characters. Unfortunately this seems to break down in some cases. For example, there is no `count()` method that takes a closure. In my case I'm trying to count vowels, but you might want to count upper case letters or anything else like that. Does it make sense to extend all the Iterable methods and properties to CharSequence as well? Or should developers turn a string into a list, perform the processing and then convert it back? Either way, the current setup seems a bit inconsistent. Peter --047d7bf0bfcc6fc6910516ac4358 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

One of the things I really like abo= ut Groovy is how strings can be treated as sequences of characters. Unfortu= nately this seems to break down in some cases. For example, there is no `co= unt()` method that takes a closure. In my case I'm trying to count vowe= ls, but you might want to count upper case letters or anything else like th= at.

Does it make sense to extend all the Iterable = methods and properties to CharSequence as well? Or should developers turn a= string into a list, perform the processing and then convert it back? Eithe= r way, the current setup seems a bit inconsistent.

Peter

--047d7bf0bfcc6fc6910516ac4358--