The numerical system of Sidef evaluates x/0 to +/-Inf.
x/0
+/-Inf
func div_check(a, b){ var result = a/b result.abs == Inf ? nil : result } say div_check(10, 2) # 5 say div_check(1, 0) # nil (detected)
Alternatively, we can do:
func div_check(a, b){ Perl.eval("#{a} / #{b}") } say div_check(10, 2) # 5 say div_check(1, 0) # nil (detected)
Last updated 1 year ago