# Ruby Blocks and Template Method Pattern

**URL:** <https://www.ruby-forum.com/t/ruby-blocks-and-template-method-pattern/84541>\
**Category:** Ruby\
**Created:** [February 5, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/ruby-blocks-and-template-method-pattern/84541 "2007-02-05T20:36:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 5, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/ruby-blocks-and-template-method-pattern/84541/1 "2007-02-05T20:36:04Z")

</div>

I was reading the Programming Ruby book yesterday and the explanation  
for Ruby blocks sounded very similar to Template Method pattern that I  
used in other object-oriented languages.

Is my understanding correct? TIA

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 5, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/ruby-blocks-and-template-method-pattern/84541/2 "2007-02-05T20:42:04Z")

</div>

On 2/5/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I was reading the Programming Ruby book yesterday and the explanation  
> for Ruby blocks sounded very similar to Template Method pattern that I  
> used in other object-oriented languages.
> 
> Is my understanding correct? TIA

Yes, that’s one way of looking at it. Using blocks can be like  
“filling in the blank” in a template method.
