# Question about pickaxe code example

**URL:** <https://www.ruby-forum.com/t/question-about-pickaxe-code-example/186672>\
**Category:** Ruby\
**Created:** [April 11, 2010, 2:31am UTC](https://www.ruby-forum.com/t/question-about-pickaxe-code-example/186672 "2010-04-11T02:31:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuck\_taylor11243](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@chuck\_taylor11243](https://www.ruby-forum.com/u/chuck_taylor11243)\
**Post date:** [April 11, 2010, 2:31am UTC](https://www.ruby-forum.com/t/question-about-pickaxe-code-example/186672/1 "2010-04-11T02:31:32Z")

</div>

in chapter 12 of pickaxe in the tutthreads\_10.rb example there is a line

threads.each(&:join)

that appears to be doing what you would expect from the line

threads.each {|t| t.join}

I’m wondering if anyone could point me at a more general description of  
how this bit of code is doing something like turning a symbol into a  
code block? (this is totally a guess on my part)

Thanks for any light that you can shed on the matter.

-chuck

---

<div class="post-metadata">

**Author:** ![chuck\_taylor11243](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@chuck\_taylor11243](https://www.ruby-forum.com/u/chuck_taylor11243)\
**Post date:** [April 11, 2010, 11:17am UTC](https://www.ruby-forum.com/t/question-about-pickaxe-code-example/186672/2 "2010-04-11T11:17:57Z")

</div>

Chuck Taylor wrote:

> in chapter 12 of pickaxe in the tutthreads\_10.rb example there is a line
> 
> threads.each(&:join)
> 
> that appears to be doing what you would expect from the line
> 
> threads.each {|t| t.join}
> 
> I’m wondering if anyone could point me at a more general description of  
> how this bit of code is doing something like turning a symbol into a  
> code block? (this is totally a guess on my part)

You’re right, and Symbol#to\_proc is what to Google for to get the full  
details.

[http://pragdave.pragprog.com/pragdave/2005/11/symbolto\_proc.html](http://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.html)
