# Ruby program for size() method in Vector# Include matrix require"matrix"# Initialize the vector
vec1 =Vector[1,2,3]# Prints the size of vector
puts vec1.size()
Ruby
输出:
3
Ruby
例2 :
# Ruby program for size() method in Vector# Include matrix require"matrix"# Initialize the vector
vec1 =Vector[1,2,3,4,5]# Prints the size of vector
puts vec1.size()