# Alternative to the Symbol#to\_proc hack

**URL:** <https://www.ruby-forum.com/t/alternative-to-the-symbol-to-proc-hack/97631>\
**Category:** Ruby\
**Created:** [July 8, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/alternative-to-the-symbol-to-proc-hack/97631 "2006-07-08T21:42:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [July 8, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/alternative-to-the-symbol-to-proc-hack/97631/1 "2006-07-08T21:42:39Z")

</div>

I’ve always been in two minds about the Symbol#to\_proc hack, it’s  
clever but adds a bit of line noise. Then I figured you can turn it  
around:

class String  
def everything\_in(e)  
e.map { |u| u.send(self) }  
end  
end

> “upcase”.everything\_in %w( i am an array )  
> =\> [“I”, “AM”, “AN”, “ARRAY”]

It’s a bit nasty because in 1.8 it can call private methods, but I  
kinda like it. And it’s not much use if you want to pass arguments  
either.

Not sure if it’s been done before either.

Ashley
