|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ O4 Z% ~( B: ]/ S$ I其中有一段如下
- c2 P, x% _; X. _6 Y; Uask turtles with [ infected? = true ]
8 G/ \9 ~, c0 y7 n6 o9 X我原本以为这句会回传『所有』infected? = true 的 turtle: x$ ^* p* g0 H! z
但看结果似乎不是这样。
" w b4 ~; c3 `: S: W$ @1 O% L& U7 w# T
假设所有符合条件的有 5 笔
' t T- q& y, R* p1 {5 Z' Z+ n有时候回传 1 笔,有时回传 3 笔,是不固定的
. C, @0 T( X1 a! ]: E [/ s x8 d) v回头查语法定义$ }1 `7 C# F- _) Y4 }" o0 O
with
# E t0 K0 l1 M. ^3 I8 T" nagentset with [reporter]$ D$ M) t7 _; [/ m) S
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.8 c+ }1 S/ [- ]+ W) C+ y9 S
它只说回传 agents satisfying the given condition
4 L/ \/ M% L& N4 j2 h; P2 d4 `是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 s- ]/ ~3 e- O B. I
' }5 _- I% z K4 f3 B想确定一下
# H4 J$ f( s* r4 @+ O- ?4 P+ q. L谢谢!
# |9 a' ^" M' f* D |
|