Ruby | Vector zero?() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The zero?() is an inbuilt method in Ruby returns boolean value true if all elements of vector are equals to zero otherwise false Syntax: vec1.zero?() Parameters: The function accepts no parameter Return Value: It returns boolean value true if all elements of vector are equals to zero otherwise false Example 1: Ruby # Ruby program for zero?() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[0, 0, 0] # Prints boolean value puts vec1.zero?() Output: true Example 2: Ruby # Ruby program for zero?() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[0, 1, 3] # Prints boolean value puts vec1.zero?() Output: false Comment More infoAdvertise with us Next Article Ruby | Vector r() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads 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 #Ru 1 min read 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 #Ru 1 min read Ruby | Vector r() function The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector r() function The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector eql?() function The eql?() is an inbuilt method in Ruby returns boolean value true if two vectors are same otherwise false Syntax: vec1.eql?(vec2) Parameters: The function accepts a single vector as parameters Return Value: It returns boolean value true if two vectors are same otherwise false Example 1: Ruby # Ruby 1 min read Ruby | Vector eql?() function The eql?() is an inbuilt method in Ruby returns boolean value true if two vectors are same otherwise false Syntax: vec1.eql?(vec2) Parameters: The function accepts a single vector as parameters Return Value: It returns boolean value true if two vectors are same otherwise false Example 1: Ruby # Ruby 1 min read Like