# Send to access private members

**URL:** <https://www.ruby-forum.com/t/send-to-access-private-members/81185>\
**Category:** Ruby\
**Created:** [January 6, 2007, 2:06am UTC](https://www.ruby-forum.com/t/send-to-access-private-members/81185 "2007-01-06T02:06:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 6, 2007, 2:06am UTC](https://www.ruby-forum.com/t/send-to-access-private-members/81185/1 "2007-01-06T02:06:17Z")

</div>

I’m a confused about why the following code works:

class Foo  
private  
def hello  
puts “hello”  
end  
end  
f = Foo.new  
f.send(:hello)

whereas  
f.hello will obviously fail.

I have tried this with private member setting as well and it also works.  
Is send supposed to operate this way? The rdoc for it don’t seem to  
mention this. Thanks!

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/send-to-access-private-members/81185/2 "2007-01-06T19:30:23Z")

</div>

Hi –

On Sat, 6 Jan 2007, David W. wrote:

> whereas  
> f.hello will obviously fail.
> 
> I have tried this with private member setting as well and it also works.  
> Is send supposed to operate this way? The rdoc for it don’t seem to  
> mention this. Thanks!

Yes, send ignores the private status. In 2.0 there will be a version  
of send that doesn’t and one that does. It’s not certain what they’ll  
be called (but if you have nothing to do for the next week or two you  
can look at the discussions about it 🙂

David
