【发布时间】:2019-10-28 22:20:32
【问题描述】:
我试图通过 for all 循环运行包含 Brewage 对象的集合中的每个元素。但是当我尝试这样做时,返回值会变得混乱。
循环函数:
public pure Scan: set of Brewage ==> Brewage
Scan(brewage) ==
for all q in set brewage do
return q
Brewage 构造函数:
public StringType = seq of char;
public StringLabel = seq of char;
public Char = char;
instance variables
type : StringType;
label : StringLabel;
deposit : Char;
operations
public Brewage: StringType * StringLabel * Char ==> Brewage
Brewage(ty, la, de) ==
( type := ty;
label := la;
deposit := de
);
我得到的错误是在扫描功能中,如下:
操作返回 void 值。实际:(() | Brewage) 预期:Brewage
【问题讨论】: