`
jsntghf
  • 浏览: 2476387 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

abort的使用

阅读更多

很多人可能会这样用:

 

def stop_error(message)
  puts "ERROR: #{message}"
  exit(1)
end

stop_error "file doesn't exist!" unless File.exist?(file)

 

其实,ruby已经为我们内置了一个abort方法。

 

abort "file doesn't exist!" unless File.exist?(file)

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics