gpt4 book ai didi

ruby - 不能在 fxri 中打印( pretty-print )吗? ( ruby )

转载 作者:太空宇宙 更新时间:2023-11-03 17:27:34 25 4
gpt4 key购买 nike

这里有一些来自 fxri 的复制/粘贴。为什么会发生这种情况,我该如何解决? ruby 版本是; ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] 在 64 位 Windows 7 上。

irb(main):334:0> pp "a"
NoMethodError: undefined method `<<' for #<FXIrb:0x6229524>
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:146:in `text'
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:198:in `group'
from ..../Ruby/lib/ruby/1.8/pp.rb:140:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/pp.rb:119:in `guard_inspect_key'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:60:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `each'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `pp'
from (irb):334
from :0

irb(main):335:0> a = {'a', 'b', 'c', 'd'}
=> {"a"=>"b", "c"=>"d"}
irb(main):336:0> a
=> {"a"=>"b", "c"=>"d"}
irb(main):337:0> pp a
NoMethodError: undefined method `<<' for #<FXIrb:0x6229524>
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:146:in `text'
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:198:in `group'
from ..../Ruby/lib/ruby/1.8/pp.rb:140:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/pp.rb:119:in `guard_inspect_key'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:60:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `each'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `pp'
from (irb):337
from :0

irb(main):338:0> ary = Array.new(5) {|i| Array.new(5) {|j| i*j } }
=> [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]
irb(main):339:0> pp ary
NoMethodError: undefined method `<<' for #<FXIrb:0x6229524>
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:146:in `text'
from ..../Ruby/lib/ruby/1.8/prettyprint.rb:198:in `group'
from ..../Ruby/lib/ruby/1.8/pp.rb:140:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/pp.rb:119:in `guard_inspect_key'
from ..../Ruby/lib/ruby/1.8/PP.rb:77:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:60:in `pp'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `each'
from ..../Ruby/lib/ruby/1.8/PP.rb:59:in `pp'
from (irb):339
from :0

最佳答案

尝试明确要求 pp

require "pp"

如果这不起作用,请尝试升级到 ruby​​ 1.8.7 或使用另一个“ pretty-print ”,例如 awesome print

关于ruby - 不能在 fxri 中打印( pretty-print )吗? ( ruby ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3370043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com