📄 11 - evaluating code in an earlier context.rb
字号:
def broken_print_variable(var_name) eval %{puts "The value of #{var_name} is " + #{var_name}.to_s}end#---tin_snips = 5broken_print_variable('tin_snips')# NameError: undefined local variable or method `tin_snips' for main:Objectvar_name = 'tin_snips'eval %{puts "The value of #{var_name} is " + #{var_name}.to_s}# The value of tin_snips is 5#---def print_variable(var_name, binding) eval %{puts "The value of #{var_name} is " + #{var_name}.to_s}, bindingendvice_grips = 10print_variable('vice_grips', binding)# The value of vice_grips is 10#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -