# The fun continues

**URL:** <https://www.ruby-forum.com/t/the-fun-continues/62423>\
**Category:** Ruby\
**Created:** [June 4, 2006, 4:16pm UTC](https://www.ruby-forum.com/t/the-fun-continues/62423 "2006-06-04T16:16:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [June 4, 2006, 4:16pm UTC](https://www.ruby-forum.com/t/the-fun-continues/62423/1 "2006-06-04T16:16:03Z")

</div>

class Class  
def to\_proc  
proc{new}  
end  
end

(1…5).map(&Array) =\> [[], [], [], [], []]  
(1…5).map(&String) =\> ["", “”, “”, “”, “”]

Mmmmmmmmm, Ruuuuuuubyyyyyyy… _drool_

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [June 4, 2006, 4:52pm UTC](https://www.ruby-forum.com/t/the-fun-continues/62423/2 "2006-06-04T16:52:41Z")

</div>

Daniel S. wrote:

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

Even cooler:

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

class Person  
def initialize(name)  
@name = name  
end

```
 def inspect
   @name.to_str
 end

```

end

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

Daniel

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [June 4, 2006, 8:29pm UTC](https://www.ruby-forum.com/t/the-fun-continues/62423/3 "2006-06-04T20:29:50Z")

</div>

Daniel S. wrote:

> Even cooler:  
> end
> 
> ```
> def inspect
> @name.to_str
> end
> 
> ```
> 
> end
> 
> %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:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [June 5, 2006, 12:12am UTC](https://www.ruby-forum.com/t/the-fun-continues/62423/4 "2006-06-05T00:12:12Z")

</div>

Daniel B. 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

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [June 4, 2006, 11:22pm UTC](https://www.ruby-forum.com/t/the-fun-continues/62423/5 "2006-06-04T23:22:31Z")

</div>

On Jun 4, 2006, at 2:27 PM, Daniel B. wrote:

> > Even cooler:  
> > @name.to\_str  
> > Dan

New syntax?
