Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Vector zero?() function

  • Last Updated : 07 Jan, 2020

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 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 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
My Personal Notes arrow_drop_up
Recommended Articles
Page :