本文簡要介紹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類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。