|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
6 F) ?+ [, U+ t0 U, T其中有一段如下
. |) W! S) ~4 X4 }: g, }" Jask turtles with [ infected? = true ] % ?. o# {9 E) D8 H( }% R- J
我原本以为这句会回传『所有』infected? = true 的 turtle6 U( W0 j2 E5 D
但看结果似乎不是这样。
! m8 ]+ g5 P- \; m+ m2 m, U R9 V& M3 K( [; M3 C+ }2 x
假设所有符合条件的有 5 笔" M% g: X: r Z
有时候回传 1 笔,有时回传 3 笔,是不固定的& O) a/ m" G" E" `9 L5 F, N/ w
回头查语法定义
7 {- G8 D, ]. D r; Z5 Kwith ' O4 h1 w5 w/ c/ ~3 {
agentset with [reporter]" |% R) n/ |; _9 Z" c; `) ^
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.
. C# u6 V+ l {它只说回传 agents satisfying the given condition
9 g& ?/ G6 B6 X8 F* D. [是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) J2 ]; R' N( r- H: U9 w u& P9 ~; n( u, f. U
想确定一下
6 r: Y0 }7 E9 b% w. v& ?/ u谢谢!
* w f( I `& b5 S" o" i |
|