How to get length of an array and sequence in Nim?
This tutorial explains about following things
- Find the size of an array in Nim
- Find length of an sequence in Nim
Array and sequence are data structures used to store(container) collection of elements. Size of these containers contains number of elements in it.
How do you find the length of an array in Nim?
Please following below steps to find the length of an array.
Array
containslen
procedure to return an size of an array. here size always fixed at compile time.
var array = ["one,"two","three"]
echo array.len # 3
How do you find the length of an Sequence in Nim?
Please following below steps to find the length of an sequence.
sequence
containslen
procedure to return an size of an sequence. size is dynamic.
var
seq = @[1, 2, 3]
echo seq.len # 3