中关村村草 发表于 2011-09-22 15:38

abort的使用

abort的使用


很多人可能会这样用:



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

stop_error "file doesn't exist!" unless File.exist?(file)
其实,ruby已经为我们内置了一个abort方法。



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

zhlong8 发表于 2011-09-22 17:28

村艹好样的

2gua 发表于 2011-09-22 20:45

村艹好样的
zhlong8 发表于 2011-09-22 17:28 http://bbs.chinaunix.net/images/common/back.gif


    :handshake
页: [1]
查看完整版本: abort的使用