# The fun continues

**URL:** https://rubytalk.org/t/the-fun-continues/27967
**Category:** ruby-talk
**Created:** [4 June 2006 14:14 UTC](https://rubytalk.org/t/the-fun-continues/27967 "2006-06-04T14:14:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Daniel\_Schierbeck](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daniel\_Schierbeck](https://rubytalk.org/u/Daniel_Schierbeck)
#### Post date: [4 June 2006 14:14 UTC](https://rubytalk.org/t/the-fun-continues/27967/1 "2006-06-04T14:14:21Z")

</div>

class Class  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{new}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;(1..5).map(&Array) =\> [[], [], [], [], []]  
&nbsp;&nbsp;&nbsp;(1..5).map(&String) =\> ["", "", "", "", ""]

Mmmmmmmmm, Ruuuuuuubyyyyyyy... \*drool\*

---

<div class="post-metadata">

### Author: ![Daniel\_Schierbeck](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daniel\_Schierbeck](https://rubytalk.org/u/Daniel_Schierbeck)
#### Post date: [4 June 2006 14:50 UTC](https://rubytalk.org/t/the-fun-continues/27967/2 "2006-06-04T14:50:48Z")

</div>

Daniel Schierbeck wrote:

> &nbsp;&nbsp;class Class  
> &nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{new}  
> &nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;end
> 
> &nbsp;&nbsp;(1..5).map(&Array) =\> [, , , ,]  
> &nbsp;&nbsp;(1..5).map(&String) =\> ["", "", "", "", ""]

Even cooler:

&nbsp;&nbsp;&nbsp;class Class  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{|\*args| new(\*args)}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;class Person  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def initialize(name)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name = name  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def inspect  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name.to\_str  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;%w(john bob jane hans).map(&Person) =\> [john, bob, jane, hans]

Daniel

---

<div class="post-metadata">

### Author: ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)
#### Post date: [4 June 2006 18:27 UTC](https://rubytalk.org/t/the-fun-continues/27967/3 "2006-06-04T18:27:02Z")

</div>

Daniel Schierbeck wrote:

> Daniel Schierbeck wrote:
> 
> > &nbsp;&nbsp;class Class  
> > &nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{new}  
> > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;(1..5).map(&Array) =\> [, , , ,]  
> > &nbsp;&nbsp;(1..5).map(&String) =\> ["", "", "", "", ""]
> 
> Even cooler:
> 
> &nbsp;&nbsp;class Class  
> &nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{|\*args| new(\*args)}  
> &nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;end
> 
> &nbsp;&nbsp;class Person  
> &nbsp;&nbsp;&nbsp;&nbsp;def initialize(name)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name = name  
> &nbsp;&nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;def inspect  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name.to\_str  
> &nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;end
> 
> &nbsp;&nbsp;%w(john bob jane hans).map(&Person) =\> [john, bob, jane, hans]
> 
> Daniel

This could have been done just as well by modifying Enumerable#map in the core, without adding new syntax.

Regards,

Dan

---

<div class="post-metadata">

### Author: ![Logan\_Capaldo](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Logan\_Capaldo](https://rubytalk.org/u/Logan_Capaldo)
#### Post date: [4 June 2006 21:19 UTC](https://rubytalk.org/t/the-fun-continues/27967/4 "2006-06-04T21:19:36Z")

</div>

New syntax?

> **···**
>
> On Jun 4, 2006, at 2:27 PM, Daniel Berger wrote:
> 
> > Daniel Schierbeck wrote:
> > 
> > > Daniel Schierbeck wrote:
> > > 
> > > > &nbsp;&nbsp;class Class  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{new}  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > > > &nbsp;&nbsp;end
> > > > 
> > > > &nbsp;&nbsp;(1..5).map(&Array) =\> [, , , ,]  
> > > > &nbsp;&nbsp;(1..5).map(&String) =\> ["", "", "", "", ""]
> > > 
> > > Even cooler:  
> > > &nbsp;&nbsp;class Class  
> > > &nbsp;&nbsp;&nbsp;&nbsp;def to\_proc  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc{|\*args| new(\*args)}  
> > > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > > &nbsp;&nbsp;end  
> > > &nbsp;&nbsp;class Person  
> > > &nbsp;&nbsp;&nbsp;&nbsp;def initialize(name)  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name = name  
> > > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > > &nbsp;&nbsp;&nbsp;&nbsp;def inspect  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name.to\_str  
> > > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > > &nbsp;&nbsp;end  
> > > &nbsp;&nbsp;%w(john bob jane hans).map(&Person) =\> [john, bob, jane, hans]  
> > > Daniel
> > 
> > This could have been done just as well by modifying Enumerable#map in the core, without adding new syntax.
> > 
> > Regards,
> > 
> > Dan

---

<div class="post-metadata">

### Author: ![Daniel\_Schierbeck](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daniel\_Schierbeck](https://rubytalk.org/u/Daniel_Schierbeck)
#### Post date: [4 June 2006 22:11 UTC](https://rubytalk.org/t/the-fun-continues/27967/5 "2006-06-04T22:11:51Z")

</div>

Daniel Berger wrote:

> This could have been done just as well by modifying Enumerable#map in the core, without adding new syntax.

Where's the fun in that? 🙂

I simply had to share my love with the wonderful #to\_proc, which continues to amaze me with its flexibility.

Daniel
