for
statement
Syntax
ForStatement :
for
IDENTIFIERin
Expression{
(Statement | Expression)+
}
A for
statement is a syntactic construct for looping over elements provided by an array type.
An example of a for
loop over the contents of an array:
Example:
contract Foo {
pub fn bar(values: Array<u256, 10>) -> u256 {
let mut sum: u256 = 0
for i in values {
sum = sum + i
}
return sum
}
}