|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 _1 s% {% q6 Y; P/ X% E g* B* h其中有一段如下
3 i7 u# T) p/ R- V% Cask turtles with [ infected? = true ] 0 h& k" O n2 y
我原本以为这句会回传『所有』infected? = true 的 turtle: R, b9 T, i7 E" j2 D3 l& C+ t$ _
但看结果似乎不是这样。
1 ^6 M7 Q' b3 g6 b3 C6 y @; N. @2 r7 n: O O
假设所有符合条件的有 5 笔
# G( H! k0 t+ C* i& i有时候回传 1 笔,有时回传 3 笔,是不固定的' @7 V' O% R- s; Q
回头查语法定义
* ~# X2 ^3 w. }3 r0 s' ^% J( G9 N. Zwith 7 J( `) }/ |7 P) V1 I" h L! J
agentset with [reporter]. w6 p0 [9 g0 |9 {& i! b2 n" y
Takes 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' W( U( P0 c8 Z它只说回传 agents satisfying the given condition
# G" N0 H9 B& w) V7 i& }是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 V1 ?, H+ _$ p0 A7 j" C: p) o
( ], F% v, _/ l+ u3 @7 Z. J0 v
想确定一下
7 {* J4 B9 Q C+ m! E. @谢谢!
0 T- S2 B( O$ N& Q9 c3 Q |
|