⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11 - evaluating code in an earlier context.rb

📁 O Reilly Ruby Cookbook source code
💻 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 + -