|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 g% M3 n: I! G& ^/ A; k
其中有一段如下
/ p6 B! g, a" cask turtles with [ infected? = true ]
4 K D8 i# _ U- K- L5 h我原本以为这句会回传『所有』infected? = true 的 turtle
1 F/ t p; a) M* M* L' _: [8 C但看结果似乎不是这样。
! s5 {6 F: b+ j. ^- b
2 a1 w, Y/ H4 D2 ~1 F* S假设所有符合条件的有 5 笔& y0 p/ u9 x f! D& I
有时候回传 1 笔,有时回传 3 笔,是不固定的" E+ l6 K- s/ c( t }
回头查语法定义
! H" ^- M; D. N: Y) i) i! H: L m, Mwith % Q1 a; X; F* M( j' M
agentset with [reporter]
r& l+ E9 @) O7 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.
/ S E/ M/ I+ s- J! \1 e% r! E+ b' B它只说回传 agents satisfying the given condition4 c, J; ^. o1 Z9 z$ |! `
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' r& s+ N+ b2 E1 M& O3 O
+ G5 @& z8 E: U2 y想确定一下3 F2 c6 r! N1 J* v. K* ~% [
谢谢!+ a; D7 G. ]+ s+ y0 \$ a- D; U
|
|