Ada 编程/属性/'Length
外观
'Length 是一个数组类型属性。它可以带或不带输入参数使用。
不带输入参数时,'Length 是一个整数,表示数组类型的第一维的长度。
带输入参数时,'Length(N) 是一个整数,表示数组类型的第 N 维的长度。N 必须是一个正数,位于数组的维度范围内。
如果你声明
typeMy_Vectorisarray(1 .. 7)ofInteger;typeMy_Matrixisarray(1 .. 5, 1 .. 10)ofInteger;
那么
pragmaAssert (My_Vector'Length = 7);pragmaAssert (My_Matrix'Length(1) = 5);pragmaAssert (My_Matrix'Length(2) = 10);pragmaAssert (My_Vector'Length(1) = My_Vector'Length);pragmaAssert (My_Matrix'Length(1) = My_Matrix'Length);
- 13.3 操作和表示属性 (注释)
- 附录 K 语言定义属性 (注释)
