# \[RCR\] Expose iv\_get/iv\_set to Ruby

**URL:** <https://rubytalk.org/t/rcr-expose-iv-get-iv-set-to-ruby/5451>\
**Category:** ruby-talk\
**Created:** [1 April 2003 04:08 UTC](https://rubytalk.org/t/rcr-expose-iv-get-iv-set-to-ruby/5451 "2003-04-01T04:08:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin\_Ziegler2](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Austin\_Ziegler2](https://rubytalk.org/u/Austin_Ziegler2)\
**Post date:** [1 April 2003 04:08 UTC](https://rubytalk.org/t/rcr-expose-iv-get-iv-set-to-ruby/5451/1 "2003-04-01T04:08:42Z")

</div>

I have a potential need to deal with all of the instance variables in  
an object. (I say potential because I’m porting and the original code  
does this. After I port this and refactor for Ruby, the need may go  
away – but I don’t know.)

What I need to do is basically:

self.instance\_variables.each do |key|  
to\_free \<\< self.iv\_get(key)  
self.iv\_set(key, nil)  
end

Now, rb\_iv\_set/rb\_iv\_get aren’t visible from the Ruby side  
(apparently), but they are visible from the C side. Are there good  
reasons to not allow this, or can we modify it so that iv\_get and  
iv\_set (or better names for them) are available as private methods to  
go along with instance\_variables?

-austin  
– Austin Ziegler, [austin@halostatue.ca](mailto:austin@halostatue.ca) on 2003.03.31 at 23:02:53

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [1 April 2003 05:13 UTC](https://rubytalk.org/t/rcr-expose-iv-get-iv-set-to-ruby/5451/2 "2003-04-01T05:13:37Z")

</div>

Hi,

> **···**
>
> At Tue, 1 Apr 2003 13:08:42 +0900, Austin Ziegler wrote:
> 
> > Now, rb\_iv\_set/rb\_iv\_get aren’t visible from the Ruby side  
> > (apparently), but they are visible from the C side. Are there good  
> > reasons to not allow this, or can we modify it so that iv\_get and  
> > iv\_set (or better names for them) are available as private methods to  
> > go along with instance\_variables?
> 
> Kernel#instance\_variable\_get and #instance\_variable\_set are  
> added in 1.8.
> 
> –  
> Nobu Nakada
