本文简要介绍ruby语言中 XMP类
的用法。
irb 的示例打印机。
它很像标准库 PrettyPrint
,在运行时显示每个表达式的值。
为了使用这个库,你必须首先要求它:
require 'irb/xmp'
现在,您可以利用 Object#xmp
便捷方法。
xmp <<END
foo = "bar"
baz = 42
END
#=> foo = "bar"
#==>"bar"
#=> baz = 42
#==>42
您还可以创建一个 XMP
对象,并带有一个可选的绑定来打印给定绑定中的表达式:
ctx = binding
x = XMP.new ctx
x.puts
#=> today = "a good day"
#==>"a good day"
ctx.eval 'today # is what?'
#=> "a good day"
相关用法
- Ruby XMP.puts用法及代码示例
- Ruby Time tv_sec用法及代码示例
- Ruby MatchData.pre_match用法及代码示例
- Ruby Symbol capitalize用法及代码示例
- Ruby Matrix lup()用法及代码示例
- Ruby SizedQueue clear()用法及代码示例
- Ruby Object.instance_variable_get用法及代码示例
- Ruby Spotter.spot_op_asgn2_for_name用法及代码示例
- Ruby Float arg()用法及代码示例
- Ruby WIN32OLE_METHOD#visible?用法及代码示例
- Ruby Matrix unitary?()用法及代码示例
- Ruby Integer.nobits?用法及代码示例
- Ruby Kernel.local_variables用法及代码示例
- Ruby StringScanner skip_until用法及代码示例
- Ruby StringScanner search_full用法及代码示例
- Ruby Matrix symmetric?()用法及代码示例
- Ruby CStructEntity.[]=用法及代码示例
- Ruby BigMath.cos用法及代码示例
- Ruby Vertex.==用法及代码示例
- Ruby Array.push用法及代码示例
- Ruby Date.valid_civil?用法及代码示例
- Ruby Generator模块用法及代码示例
- Ruby Array.hash用法及代码示例
- Ruby Hash.reject用法及代码示例
- Ruby ARGF.path用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 XMP类。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。