Copy-paste fix pattern
fn main() {
array names = ["Ada", "Grace"]
u256 at = 1
if (at < len(names)) {
println(names[at])
} else {
println("No item at that index")
}
}
ClosedBit Docs
ClosedBit error docs
Array index out of range. The program tried to read or write an array slot that does not exist.
The program tried to read or write an array slot that does not exist.
Check len(array), clamp the index to 0..len(array)-1, or create the missing item before assignment.
fn main() {
array names = ["Ada", "Grace"]
u256 at = 1
if (at < len(names)) {
println(names[at])
} else {
println("No item at that index")
}
}