|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( c* V: o$ F5 o, ~/ c+ ]$ F其中有一段如下
) P7 Y3 t& e1 p# aask turtles with [ infected? = true ] , Y; }. e4 O p' R% y
我原本以为这句会回传『所有』infected? = true 的 turtle
3 [( r7 w" {8 G# [& [. B% J0 ^但看结果似乎不是这样。
; W* v- \& ?6 \( Q
+ f3 ]; x6 I' l假设所有符合条件的有 5 笔3 T% b) F R3 K2 K: w2 U
有时候回传 1 笔,有时回传 3 笔,是不固定的$ L6 @* x# e) o. G
回头查语法定义0 q6 m( l" O# B O1 x7 r, C
with
+ F$ p: M1 X# {7 G6 Tagentset with [reporter]8 p. D f; g+ K
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.
8 V4 d9 P! o6 }- ]' o. x! [它只说回传 agents satisfying the given condition
% U T. j% s) z7 c+ D* \' G+ i' S是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . N8 W9 z& ?+ o
) j: p8 D: f" }; J/ p
想确定一下6 _+ [0 }8 c/ R$ d, e3 C5 A
谢谢!
$ t' V& S5 @0 y" u. { |
|