# Is this pattern current?

**URL:** <https://www.ruby-forum.com/t/is-this-pattern-current/121279>\
**Category:** Ruby\
**Created:** [November 26, 2007, 1:02pm UTC](https://www.ruby-forum.com/t/is-this-pattern-current/121279 "2007-11-26T13:02:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [November 26, 2007, 1:02pm UTC](https://www.ruby-forum.com/t/is-this-pattern-current/121279/1 "2007-11-26T13:02:55Z")

</div>

Hi list

I just wrote

o = super( \*args)  
my\_init.bind( o ).call( \*args )  
o

I write code of this patter way too often, I was just thinking that I  
really would like to have  
module Kernel  
def with\_value\_return\_value a\_value, &blk  
blk.call a\_value

end  
end

–

[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

All truth passes through three stages. First, it is ridiculed. Second,  
it is violently opposed. Third, it is accepted as being self-evident.  
Schopenhauer (attr.)

---

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [November 26, 2007, 1:04pm UTC](https://www.ruby-forum.com/t/is-this-pattern-current/121279/2 "2007-11-26T13:04:41Z")

</div>

On Nov 26, 2007 1:00 PM, Robert D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
OOps finger just slipping to the nice Enter key ☹

> module Kernel  
> def with\_value\_return\_value a\_value, &blk  
> blk.call a\_value  
> a\_value
> 
> end  
> end

Now of course I can write

with\_value\_return\_value( super(\*args) ) do |o|  
my\_init.bind(o).call(\*args)  
end

Does someone have a name for this? (mine is a joke, a bad one)

Cheers  
Robert  
[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

All truth passes through three stages. First, it is ridiculed. Second,  
it is violently opposed. Third, it is accepted as being self-evident.  
Schopenhauer (attr.)

---

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [November 26, 2007, 1:38pm UTC](https://www.ruby-forum.com/t/is-this-pattern-current/121279/3 "2007-11-26T13:38:03Z")

</div>

> with\_value\_return\_value( super(\*args) ) do |o|  
> my\_init.bind(o).call(\*args)  
> end  
> AFAIK this is called #returning in both facets and activesupport. There  
> has been a discussion about it a while ago.

[http://groups.google.com/group/comp.lang.ruby/browse\_thread/thread/70dadf80a5f57e1f/4433b25ea8402832](http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/70dadf80a5f57e1f/4433b25ea8402832)

---

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [November 26, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/is-this-pattern-current/121279/4 "2007-11-26T14:04:35Z")

</div>

On Nov 26, 2007 1:37 PM, Sylvain J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > with\_value\_return\_value( super(\*args) ) do |o|  
> > my\_init.bind(o).call(\*args)  
> > end  
> > AFAIK this is called #returning in both facets and activesupport. There  
> > has been a discussion about it a while ago.
> 
> [http://groups.google.com/group/comp.lang.ruby/browse\_thread/thread/70dadf80a5f57e1f/4433b25ea8402832](http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/70dadf80a5f57e1f/4433b25ea8402832)  
> Very interesting discussion, and the name seems quite ok with me.  
> As this was more than a year ago I dare adding some reasoning.

What I like most on this idiom is that the local variable is hiding in  
the scope, but much more importantly that you can think on a higher  
level

o = something  
…  
…  
…  
o

just seems low level and I daresay that the final little o, so  
important, will be forgotten quite often

returning( something ) do |o|  
…  
…  
…  
end

seems so much more robust.

And for what concerns #tap, well impossible to keep a name like that in  
mind :(.

BTW good to know it’s in Facets.

Cheers  
Robert

> –  
> Sylvain

–

[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

All truth passes through three stages. First, it is ridiculed. Second,  
it is violently opposed. Third, it is accepted as being self-evident.  
Schopenhauer (attr.)
