|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 ~6 F2 Q- ~; `; X m
其中有一段如下
! y I/ r- k( aask turtles with [ infected? = true ] ( H. y: b$ G! G7 J# }
我原本以为这句会回传『所有』infected? = true 的 turtle/ q9 v, L n% o. l
但看结果似乎不是这样。
+ D( y) ~7 {" V
( W* O2 x/ J1 [; W, Z; Z% F假设所有符合条件的有 5 笔
% |* e5 e7 |- |2 ^2 s4 }0 A有时候回传 1 笔,有时回传 3 笔,是不固定的' L3 l/ [: j u2 @0 c
回头查语法定义3 z% Y8 l+ [ w9 F
with
5 u1 t2 T, e1 a) q: d$ Bagentset with [reporter]
7 h( A8 M+ M$ F, v$ gTakes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition.2 N( U" \) ^4 r3 k
它只说回传 agents satisfying the given condition4 y: J. l( B7 q, {2 U4 N
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
1 ^3 @& q& H+ m; A# O1 ^, e: ? h; K0 G
想确定一下5 G1 S9 w( @) O7 e/ L: z9 C3 W
谢谢!; c8 t! B- s2 I+ ?: b* F$ g( l n, w8 W
|
|