4.2.3. Subscripts

4.2.3. Subscripts

4.2.3. 下标

If an expression yields a value of an array type, then a specific element of the array value can be extracted by writing:

如果一个表达式产生一个数组类型的值,则可以通过编写以下命令提取数组的特定元素:

expression[subscript]

or multiple adjacent elements (an “array slice”) can be extracted by writing:

或多个相邻元素(“数组切片”)可以通过以下方式提取:

expression[lower_subscript:upper_subscript]

(Here, the brackets [ ] are meant to appear literally.) Each subscript is itself an expression, which must yield an integer value.

(此处的方括号应原样出现。) 每个下标本身就是一个表达式,必须是一个整数值。

In general the array expression must be parenthesized, but the parentheses can be omitted when the expression to be subscripted is just a column  reference or positional parameter. Also, multiple subscripts can be concatenated when the original array is multidimensional. For example:

通常,数组表达式必须带括号,但是当要下标的表达式只是列引用或位置参数时,可以省略括号。 同样,当原始数组为多维时,可以连接多个下标。 例如:

mytable.arraycolumn[4]

mytable.two_d_column[17][34]

$1[10:42]

(arrayfunction(a,b))[42]

The parentheses in the last example are required. See Section 8.15 for more about arrays.

最后一个示例中的括号是必需的。有关数组的更多信息,请查看第8.15节

发布了341 篇原创文章 · 获赞 53 · 访问量 88万+

猜你喜欢

转载自blog.csdn.net/ghostliming/article/details/104259254