|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! r4 g. C4 C) c" [* z其中有一段如下
: f: n c3 w/ H' e6 M6 \' |$ K- Cask turtles with [ infected? = true ] @6 ^2 v2 Z, j7 @
我原本以为这句会回传『所有』infected? = true 的 turtle
w! b ]# E% p0 Y9 f" \5 r2 G但看结果似乎不是这样。
/ o/ K6 J* k- K: d A$ z5 x) h# J4 f" e' ^! f8 C) j8 P( L
假设所有符合条件的有 5 笔, |8 E) O* g. U+ A
有时候回传 1 笔,有时回传 3 笔,是不固定的0 C# ^' o H: M6 d8 W# e g
回头查语法定义* u1 J4 a8 W, T/ ]7 n# _0 {
with
, l( x2 C" Q( }; E" l# Eagentset with [reporter]
# x! h5 l. V1 N% JTakes 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.
: J* \& B& x$ Q0 v$ y5 X* k它只说回传 agents satisfying the given condition* b& g. Z: _; J: N. D; T
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + x0 x: W0 h b1 d5 T" t G
* u" m7 E4 `1 }7 G& K想确定一下
0 \2 [% I8 o+ u/ {6 m+ E谢谢!' b+ b7 T+ N" @/ X
|
|