Ruby | Vector zero() function Last Updated : 19 Jan, 2021 Improve Improve Like Article Like Save Share Report The zero() is an inbuilt method in Ruby returns the vector of size N with elements equals to 0. Syntax: Vector.zero(N) Parameters: The function accepts a parameter which represents the size of the array. Return Value: It returns the vector of size N with elements equals to 0. Example 1: Ruby #Ruby program for zero method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector.zero(4) #prints the new vector puts vec1 Output: Vector[0, 0, 0, 0] Example 2: Ruby #Ruby program for zero method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector.zero(3) #prints the new vector puts vec1 Output: Vector[0, 0, 0] Like Article Suggest improvement Previous Ruby | Vector norm() function Next Ruby | Vector [] method Share your thoughts in the comments Add Your Comment Please Login to comment...