【问题标题】:How do I rescue a multiple assignment in Ruby?如何拯救 Ruby 中的多项任务?
【发布时间】:2010-11-08 20:18:17
【问题描述】:
foo, bar = 1, 0/0 rescue 0, 0 # this won't work
foo.should eql 0
bar.should eql 0

我该如何做这个通行证?

【问题讨论】:

  • 我不认为你的意思是后两行中的ab...

标签: ruby exception-handling


【解决方案1】:
foo, bar = ([1, 0/0] rescue [0, 0])

【讨论】:

    猜你喜欢
    • 2010-10-07
    • 2010-12-15
    • 2013-11-27
    • 2013-06-28
    • 2013-06-12
    • 2015-07-03
    • 2012-07-31
    • 2011-01-12
    • 1970-01-01
    相关资源
    最近更新 更多