# Pickaxe Question

**URL:** <https://www.ruby-forum.com/t/pickaxe-question/64722>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/pickaxe-question/64722 "2006-08-15T14:18:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/pickaxe-question/64722/1 "2006-08-15T14:18:15Z")

</div>

On page 53 of the Pickaxe Book there is a little example illustrating  
Proc parameters:

songlist = SongList.new  
class JukeboxButton \< Button  
def initialize(label, &action)  
super(label)  
@action = action  
end  
def button\_pressed  
@action.call(self)  
end  
end  
start\_button = JukeboxButton.new(“Start”) { songlist.start }  
pause\_button = JukeboxButton.new(“Pause”) { songlist.pause }

If I understand this example correctly, we are supposed to assume  
that the  
mapping of the instances of JukeboxButton to actual hardware buttons  
happens, by magic, when we call the button initializer and pass it  
the appropriate string with the super(label) message. But if that’s  
the case, I don’t understand why button\_pressed needs to pass self as  
an argument to the @action.call message. It seems like the  
songlist.start and songlist.pause methods just drop the argument.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/pickaxe-question/64722/2 "2006-08-15T14:18:17Z")

</div>

On Aug 12, 2006, at 14:21, Chris G. wrote:

> If I understand this example correctly, we are supposed to assume  
> that the  
> mapping of the instances of JukeboxButton to actual hardware  
> buttons happens, by magic, when we call the button initializer and  
> pass it the appropriate string with the super(label) message. But  
> if that’s the case, I don’t understand why button\_pressed needs to  
> pass self as an argument to the @action.call message. It seems like  
> the songlist.start and songlist.pause methods just drop the argument.

Yeah, that’s true. I don’t need to pass it in: it was there from the  
original example, where the block could interrogate the state of the  
button. Sorry it was confusing.

Dave

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/pickaxe-question/64722/3 "2006-08-15T14:18:18Z")

</div>

On Aug 12, 2006, at 12:41 PM, Dave T. wrote:

> Yeah, that’s true. I don’t need to pass it in: it was there from  
> the original example, where the block could interrogate the state  
> of the button. Sorry it was confusing.

Thanks for the quick reply, Dave. I’ve been using Ruby off and on for  
awhile now but I never felt that i dug in and really understood it.  
Hence the picky questions.

* * *

Neither a man nor a crowd nor a nation can be trusted to act humanely  
or to think sanely under the influence of a great fear.

-Bertrand Russell, philosopher, mathematician, author, Nobel laureate  
(1872-1970)
