|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 I7 H2 `# }. d, S' i6 B
其中有一段如下
3 f2 g6 m# O. Lask turtles with [ infected? = true ]
* s# s# j) }* y: w1 U# N: F8 D R我原本以为这句会回传『所有』infected? = true 的 turtle. b$ t. Y1 T- w9 u! [0 K+ U6 ~
但看结果似乎不是这样。, o( Z, R5 l5 K [% d( w$ Q
, L6 { R2 H8 j0 ~6 Y( F3 d# z
假设所有符合条件的有 5 笔
: o r0 y: p8 u" s A& O' u有时候回传 1 笔,有时回传 3 笔,是不固定的
+ f! p( N8 e. A+ n. D2 O. e% z9 a) z回头查语法定义
) K- h# c: b! b- `with
5 [. m* f: _5 H9 i) g J9 fagentset with [reporter]7 @, w! e1 F( T% R4 R
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.
0 }8 g5 x: E8 v8 v$ L它只说回传 agents satisfying the given condition! W& Q, C% a0 _9 j p0 O+ U
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
" a' f0 N) }2 H8 N$ b2 y/ _* b$ M- }1 G( u
想确定一下
: P+ h6 k% M3 W* z! ?8 r& l2 N谢谢!
e5 f% X% w- @ r, o- [. H |
|