本文简要介绍ruby语言中 Binding.local_variables
的用法。
用法
local_variables → Array
将绑定的局部变量的名称作为符号返回。
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
此方法是以下代码的简短版本:
binding.eval("local_variables")
相关用法
- Ruby Binding.local_variable_defined?用法及代码示例
- Ruby Binding.local_variable_set用法及代码示例
- Ruby Binding.local_variable_get用法及代码示例
- Ruby Binding.eval用法及代码示例
- Ruby Binding.irb用法及代码示例
- Ruby Binding类用法及代码示例
- Ruby BigMath.cos用法及代码示例
- Ruby BigDecimal.self >用法及代码示例
- Ruby BigMath.sin用法及代码示例
- Ruby BigDecimal.self >=用法及代码示例
- Ruby BigDecimal.floor用法及代码示例
- Ruby BigDecimal.to_s用法及代码示例
- Ruby BigDecimal.to_d用法及代码示例
- Ruby BigDecimal.save_rounding_mode用法及代码示例
- Ruby BigDecimal modulo用法及代码示例
- Ruby BigDecimal infinite?用法及代码示例
- Ruby BigDecimal.to_digits用法及代码示例
- Ruby BigDecimal.add用法及代码示例
- Ruby BigDecimal.save_exception_mode用法及代码示例
- Ruby BigDecimal to_f()用法及代码示例
- Ruby BigDecimal to_r()用法及代码示例
- Ruby BigDecimal exponent用法及代码示例
- Ruby BigDecimal.ceil用法及代码示例
- Ruby BigDecimal log()用法及代码示例
- Ruby BigDecimal sub()用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Binding.local_variables。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。