如何在功能的old
子句中使用ensure
关键字,当前语句在运行时似乎无效
relationships: CHAIN -- any chain
some_feature
do
(...)
ensure
relationship_added: attached relationships as l_rel implies
attached old relationships as l_old_rel and then
l_rel.count = l_old_rel.count
end
答案 0 :(得分:1)
有2种情况需要考虑:原始引用为'n'
时,而—不是:
void
断言的直觉如下:
attached relationships as r implies r.count =
old (if attached relationships as o then o.count + 1 else 1 end)
在退出时是relationships
,我们不在乎Void
。count
,则其值比旧值多了一个。可以附加旧值或使用relationships
:
Void
; 1
,则新项目数为Void
。