我有一个block!
x: ["one" "two" "three"]
index? find x "two"
返回...阿拉伯数字
index? find x "four"
回归...
** Script Error: index? expected series argument of type: series port
** Near: index? find x "twos"
索引的最佳方法是什么? 返回none
而不是错误?
>> help index?
USAGE:
INDEX? series /xy
DESCRIPTION:
Returns the index number of the current position in the series.
INDEX? is an action value.
ARGUMENTS:
series -- (Type: series port)
REFINEMENTS:
/xy -- Returns index as an XY pair offset.
索引? 期待一个系列。如果参数为 none,则会引发错误。
>> find x "four"
== none
您可以检查参数是否存在或是一个系列或防止错误,例如
>> if series? i: find x "four" [index? i]
== none
或
>> attempt [index? find x "four" none]
== none