# Operator out of string

**URL:** <https://www.ruby-forum.com/t/operator-out-of-string/135024>\
**Category:** Ruby\
**Created:** [April 17, 2008, 9:15am UTC](https://www.ruby-forum.com/t/operator-out-of-string/135024 "2008-04-17T09:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ec9cab/32.png) [@kelt](https://www.ruby-forum.com/u/kelt)\
**Post date:** [April 17, 2008, 9:15am UTC](https://www.ruby-forum.com/t/operator-out-of-string/135024/1 "2008-04-17T09:15:41Z")

</div>

Hey,

I am a newbee in Ruby and since the language has many nice features it  
struck me obvioous that it must be possible to evaluate a string in  
such a way that it produces the corresponding operator. E.g.: “+”  
would become a simple plus sign, thus allowing me to pass “+” as a  
function to be done on two integers.

Thank you

kelt

---

<div class="post-metadata">

**Author:** ![kelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ec9cab/32.png) [@kelt](https://www.ruby-forum.com/u/kelt)\
**Post date:** [April 17, 2008, 9:22am UTC](https://www.ruby-forum.com/t/operator-out-of-string/135024/2 "2008-04-17T09:22:14Z")

</div>

kelt wrote:

> Hey,
> 
> I am a newbee in Ruby and since the language has many nice features it  
> struck me obvioous that it must be possible to evaluate a string in  
> such a way that it produces the corresponding operator. E.g.: “+”  
> would become a simple plus sign, thus allowing me to pass “+” as a  
> function to be done on two integers.
> 
> Thank you
> 
> kelt

2.send("+",5) # =\> 7

---

<div class="post-metadata">

**Author:** ![kelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ec9cab/32.png) [@kelt](https://www.ruby-forum.com/u/kelt)\
**Post date:** [April 17, 2008, 10:01am UTC](https://www.ruby-forum.com/t/operator-out-of-string/135024/3 "2008-04-17T10:01:08Z")

</div>

Thank you very much Marc,

that was exactly what I was looking for.
