From: Ryan Davis Date: 2010-12-15T18:06:55+09:00 Subject: Re: How do I define virtual global variable in ruby? On Dec 15, 2010, at 00:07 , femto Zheng wrote: > Hello all, > in ruby c source code, there is > [...] > 3370: rb_*define_virtual*_variable("$&", last_match_getter, 0); > > [...] > > so actually this looks like global variable, but when you get/set it, > it will run thru a function, > How do I do it in Ruby code? make a global variable running through my > customized get/set procedure? Without using a hacky trick like calling rb_define_virtual_variable through FFI or DL, I don't think you can.