【发布时间】:2017-02-23 02:40:25
【问题描述】:
我要记录的一个示例如下:
/**
* @return {boolean}
*/
Contains(rectangle_or_x, y, tolerance) {
if (rectangle_or_x instanceof Rectangle) { return ((rectangle_or_x.X >= this._x) && (rectangle_or_x.Y >= this._y) && (rectangle_or_x.Right <= this._right) && (rectangle_or_x.Bottom <= this._bottom)); }
if ((tolerance === undefined) || (tolerance === null) || (!Rectangle._isNumeric(tolerance))) {
if ((rectangle_or_x < this._x) || (y < this._y) || (rectangle_or_x > this._right) || (y > this._bottom)) { return (false); }
} else if (((rectangle_or_x + tolerance) < this._x) || ((y + tolerance) < this._y) || ((rectangle_or_x - tolerance) > this._right) || ((y - tolerance) > this._bottom)) { return (false); }
return (true);
}
其中有 3 个可能的调用,其中一个可以忽略,因为它基于可选的 tolerance 参数,但基数两个以排他方式重叠:
Contains(Rectangle rectangle_or_x)
Contains(Number rectangle_or_x, Number y[, Number tolerance])
鉴于不同的类型(我知道 JavaScript 是无类型的,但就示例而言,涉及到确定的类型)是否可以使用 JSDoc 创建单独的 @param 值集(主要用于 WebStorm 中的智能感知,但理论上也适用于后续文档。)
【问题讨论】: