Ruby | Vector zero?() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes 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 zero?() function 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 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 hash() function The hash() is an inbuilt method in Ruby returns hash code of the vector Syntax: vec1.hash() Parameters: The function accepts no parameter. Return Value: It returns hash code of the vector. Example 1: Ruby # Ruby program for hash() method in Vector # Include matrix require "matrix" # Initia 1 min read Ruby | Vector norm() function The norm() is an inbuilt method in Ruby returns the pythagorean distance of the vector. Syntax: vec1.norm() Parameters: The function accepts no parameter Return Value: It pythagorean distance of the vector Example 1: Ruby # Ruby program for norm() method in Vector # Include matrix require "matr 1 min read Ruby | Vector to_a() function The to_a() is an inbuilt method in Ruby returns the array with elements of vector Syntax: vec1.to_a() Parameters: The function accepts no parameter Return Value: It returns the array with elements of vector Example 1: Ruby # Ruby program for to_a() method in Vector # Include matrix require "mat 1 min read Ruby | Vector size() function The size() is an inbuilt method in Ruby returns the number of elements in the vector Syntax: vec1.size() Parameters: The function accepts no parameter Return Value: It returns the number of elements in the vector Example 1: Ruby # Ruby program for size() method in Vector # Include matrix require 1 min read Ruby | Vector round() function The round() is an inbuilt method in Ruby returns a new vector with entries rounded to the given precision Syntax: vec1.round() Parameters: The function accepts a single parameter Return Value: It returns a new vector with entries rounded to the given precision Example 1: Ruby # Ruby program for roun 1 min read Ruby | Vector angle_with() function The angle_with() is an inbuilt method in Ruby returns the angle between two vectors. The angle is always between 0 and π Syntax: vec1.angle_with(vec2) Parameters: The function accepts vector as parameter Return Value: It returns the angle between two vectors Example 1: CPP #Ruby program for angle 1 min read Like