# Extracting array values in Object.send

**URL:** <https://www.ruby-forum.com/t/extracting-array-values-in-object-send/81774>\
**Category:** Ruby\
**Created:** [January 13, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/extracting-array-values-in-object-send/81774 "2007-01-13T22:05:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [January 13, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/extracting-array-values-in-object-send/81774/1 "2007-01-13T22:05:08Z")

</div>

How can I exract array values when using Object.send. See the example  
below.

class TestSend

def test( arg1, arg2, arg3)  
puts arg1  
puts arg2  
puts arg3  
end

end

t = TestSend.new  
t.send(‘test’, ‘hey’, 1, ‘rrr’)

args = [‘hey’,1,‘rrr’]  
t.send(‘test’, args) #this throws an argument error, 3 for 1…

Thanks.

---

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [January 13, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/extracting-array-values-in-object-send/81774/2 "2007-01-13T22:37:01Z")

</div>

Aaron S. wrote:

> How can I exract array values when using Object.send. See the example  
> below.
> 
> class TestSend
> 
> def test( arg1, arg2, arg3)  
> puts arg1  
> puts arg2  
> puts arg3  
> end
> 
> end
> 
> t = TestSend.new  
> t.send(‘test’, ‘hey’, 1, ‘rrr’)
> 
> args = [‘hey’,1,‘rrr’]  
> t.send(‘test’, args) #this throws an argument error, 3 for 1…

Use the splat operator to expand the array into individual method  
arguments:

t.send(:test, \*args)
