public Method

Kernel.global_variables

global_variables     array

Returns an array of the names of global variables.

global_variables.grep /std/   #=> ["$stderr", "$stdout", "$stdin"]

Source Code

/*
*  call-seq:
*     global_variables    => array
*  
*  Returns an array of the names of global variables.
*     
*     global_variables.grep /std/   #=> ["$stderr", "$stdout", "$stdin"]
*/

VALUE
rb_f_global_variables()
{
   VALUE ary = rb_ary_new();
   char buf[4];
   char *s = "&`'+123456789";

   st_foreach(rb_global_tbl, gvar_i, ary);
   if (!NIL_P(rb_backref_get())) {
while (*s) {
    sprintf(buf, "$%c", *s++);
    rb_ary_push(ary, rb_str_new2(buf));
}
   }
   return ary;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.