Ruby | Vector zero() function
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
require "matrix"
vec1
= Vector.zero( 4 )
puts vec1
|
Output:
Vector[0, 0, 0, 0]
Example 2:
Ruby
require "matrix"
vec1
= Vector.zero( 3 )
puts vec1
|
Output:
Vector[0, 0, 0]
Last Updated :
19 Jan, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...