本文簡要介紹ruby語言中 ZeroDivisionError類
的用法。
嘗試將整數除以 0 時引發。
42 / 0 #=> ZeroDivisionError: divided by 0
請注意,隻有除以 0 才會引發異常:
42 / 0.0 #=> Float::INFINITY
42 / -0.0 #=> -Float::INFINITY
0 / 0.0 #=> NaN
相關用法
- Ruby Zlib.gunzip用法及代碼示例
- Ruby Zlib.deflate用法及代碼示例
- Ruby Zlib.adler32用法及代碼示例
- Ruby Zlib.inflate用法及代碼示例
- Ruby Zlib模塊用法及代碼示例
- Ruby ZStream類用法及代碼示例
- Ruby Zlib.gzip用法及代碼示例
- 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-lang.org大神的英文原創作品 ZeroDivisionError類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。