|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 q2 z) [ @" x
其中有一段如下
. F" }0 R; ~" K( r2 Fask turtles with [ infected? = true ]
. d- k7 T; ]4 W! Y我原本以为这句会回传『所有』infected? = true 的 turtle
. U9 h7 A1 F4 E) k6 x但看结果似乎不是这样。1 |& |' `% g u7 c2 L
7 T. V6 X0 N" S7 s; ?# A* g7 }
假设所有符合条件的有 5 笔
0 G4 p4 O) p U( V3 [5 t0 E有时候回传 1 笔,有时回传 3 笔,是不固定的
5 A: H, ]" F5 d# y! ~1 ?: d# L回头查语法定义
$ ] q' @( U* @8 Uwith
- D" e2 F6 F% I" I; N4 H8 Xagentset with [reporter]
5 ]2 S5 Q/ B- w" X% LTakes 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.
) |3 N: Q' _) `# u/ h它只说回传 agents satisfying the given condition
3 o1 J0 \7 ]/ R9 G5 p& N' C# k* ~是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 `' a V, y0 _# W) m) T
|1 Y8 l% p0 K: c' \2 F B& Z
想确定一下2 F. j( f1 R! B: O N# M
谢谢!
9 E4 r9 r: S' p |
|