ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "Mikael Høilund" <mikael@hoilund.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:20433] Re: Array#to_proc
Date: Tue, 9 Dec 2008 02:51:53 +0900	[thread overview]
Message-ID: <A19A733E-8271-4DE7-A3ED-FB7EDAAB1773@hoilund.org> (raw)
In-Reply-To: <20081208173046.9579BE09B0@mail.bc9.jp>

On Dec 8, 2008, at 18:24, Nobuyoshi Nakada wrote:

> Hi,
>
> At Mon, 8 Dec 2008 22:21:16 +0900,
> Florian Gilcher wrote in [ruby-core:20421]:
>> This might make sense for an Array of Symbols. But i've also seen use
>> of this
>> in other interpretations, like for chaining Arrays of procs. Other
>> uses could be
>> imagined.
>
> What about Symbol#call()?
>
>  (1..3).collect(&:*.(2))  #=> [2, 4, 6]
>


I think Jay Philips's Methodphitamine[1] does an good job at that, is  
more flexible (you can do (x * 2).to_s with it, for instance), and IMO  
has a cleaner syntax (albeit that might be a moot point in this  
context ;)).

Your example would be, with Methodphitamine:

  (1..3).collect &it * 2

[1]: http://jicksta.com/posts/the-methodphitamine

-- 
Name = "Mikael Høilund"; Email = Name.gsub %r/\s/,%#=?,#
*a=e=?=,!????,:??,?,,Email.downcase![eval(%["\\%o\\%o"]%
[?**2+?o,?\\*2])]="o";Email.gsub! %%\%c%*3%a, %?%c? % ?@
def The(s)%%\%s.%%s+%.org\n.end; :Go and print The Email

  reply	other threads:[~2008-12-08 18:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-08 12:47 [ruby-core:20418] Array#to_proc Eustáquio Rangel
2008-12-08 12:55 ` [ruby-core:20419] Array#to_proc Austin Ziegler
2008-12-08 13:21 ` [ruby-core:20421] " Florian Gilcher
2008-12-08 13:56   ` [ruby-core:20423] " Eustáquio Rangel
2008-12-08 14:08   ` [ruby-core:20424] " James Coglan
2008-12-08 17:24   ` [ruby-core:20430] " Nobuyoshi Nakada
2008-12-08 17:51     ` Mikael Høilund [this message]
2008-12-09  5:58     ` [ruby-core:20439] " Yukihiro Matsumoto

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=A19A733E-8271-4DE7-A3ED-FB7EDAAB1773@hoilund.org \
    --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).