# firstindex


返回集合在给定维度上的第一个索引。

# 语法

firstindex(collection)
firstindex(collection, d)

# 说明

firstindex(collection) 返回集合第一个索引位置,常用于获取 a[begin] 的含义。 示例


firstindex(collection, d) 返回集合在维度 d 上的第一个索引位置。 示例

# 示例

返回集合第一个索引位置
firstindex([1,2,4])
1
返回集合在维度 d 上的第一个索引位置
firstindex(rand(3,4,5), 2)
1

# 输入参数

collection - 输入集合
Array | Tuple | String | Dict 等

要获取索引的集合。

d - 指定维度
Int

用于获取在特定维度上的索引起点。

# 另请参阅

getindex | setindex! | lastindex