|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 z/ f& O4 v7 W) {0 q, @其中有一段如下
1 P$ f5 n* l" Z6 l8 D# E- uask turtles with [ infected? = true ]
0 l, a) v0 R6 W8 x我原本以为这句会回传『所有』infected? = true 的 turtle5 ^% A; {9 O7 q/ b) J1 V: C
但看结果似乎不是这样。- j7 |3 i* Q/ o% [8 J! A9 [/ k
+ r( J! {. J. u
假设所有符合条件的有 5 笔3 J7 b! _, c7 i, {
有时候回传 1 笔,有时回传 3 笔,是不固定的
8 t% A" O. z5 s$ x/ T5 b回头查语法定义
: l9 K, A5 `2 I% u% T% P- lwith ! y) r1 k5 L+ P; _/ R
agentset with [reporter], ?1 D9 m0 {3 K6 m' P% R- L
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.' A; E+ o# V) @% m
它只说回传 agents satisfying the given condition9 C: |, c0 z! B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ g9 c7 @; s# E
$ U" P' s$ P S5 l" I8 r想确定一下( @1 l q; I' s, E
谢谢!, V5 N1 K, k% t4 J" I4 q0 c! L: h; ]
|
|