method
local_variables
v2_6_3 -
Show latest stable
- Class:
Kernel
local_variables()public
Returns the names of the current local variables.
fred = 1 for i in 1..10 # ... end local_variables #=> [:fred, :i]
static VALUE
rb_f_local_variables(void)
{
struct local_var_list vars;
rb_execution_context_t *ec = GET_EC();
rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp));
unsigned int i;
local_var_list_init(&vars);
while (cfp) {
if (cfp->iseq) {
for (i = 0; i < cfp->iseq->body->local_table_size; i++) {
local_var_list_add(&vars, cfp->iseq->body->local_table[i]);
}
}
if (!VM_ENV_LOCAL_P(cfp->ep)) {
/* block */
const VALUE *ep = VM_CF_PREV_EP(cfp);
if (vm_collect_local_variables_in_heap(ep, &vars)) {
break;
}
else {
while (cfp->ep != ep) {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
}
else {
break;
}
}
return local_var_list_finish(&vars);
} Related methods
- Instance methods
- Array
- BigDecimal
- Complex
- Float
- Hash
- Integer
- Pathname
- Rational
- String
- __callee__
- __dir__
- __method__
- `
- abort
- at_exit
- autoload
- autoload?
- binding
- block_given?
- callcc
- caller
- caller_locations
- catch
- chomp
- chop
- eval
- exec
- exit
- exit!
- fail
- fork
- format
- gem_original_require
- gets
- global_variables
- gsub
- iterator?
- lambda
- load
- local_variables
- loop
- p
- pretty_inspect
- printf
- proc
- putc
- puts
- raise
- rand
- readline
- readlines
- require_relative
- select
- set_trace_func
- sleep
- spawn
- sprintf
- srand
- sub
- syscall
- system
- test
- throw
- trace_var
- trap
- untrace_var
- warn
- Class methods
- URI
- open
- pp
- Private methods
-
open_uri_original_open -
JSON -
URI -
gem -
j -
jj -
open -
open_uri_original_open -
pp -
require -
scanf -
y