我通过七种编程语言读七周内的问题之一规定: 你会如何改变/返回0如果分母为零? 我第一次尝试定义我自己/并进行代理其执行原来的/方法是这样的: Number oldSlash := Number getSlot("/")
Number/= method(x, Number oldSlash(x))
然而,这不是为我工作。做了一些Google搜索之后,我发现了一段类似的代码。我发现的代码在执行
是否有一种习惯用法,它不会重复代码,并在单元测试时检查Io中是否抛出异常? 到目前为止: threw := false
e := try(_method that should throw_)
e catch(Exception, threw = true)
if(threw not, fail("Should have thrown an Exception, but did not!")