#Ruby program for* method in Vector#Include matrixrequire"matrix"#Initialize the vector
vec1
=Vector[1,2]#Initialize the vector
x
=3#prints the new vector
puts vec1
* x
Ruby
输出:
Vector[3,6]
Ruby
例2 :
#Ruby program for* method in Vector#Include matrixrequire"matrix"#Initialize the vector
vec1
=Vector[1,2,3]#Initialize the vector
x
=3#prints the new vector
puts vec1
* x