我有一个block!
x: ["one" "two" "three"]
index? find x "two"
返回... 2
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