Ruby | Vector r() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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" # Initialize the vector vec1 = Vector[1, 2, 3] # Prints pythogras of the vector puts vec1.r() Output: 3.7416573867739413 Example 2: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1, 1, 1] # Prints pythogras of the vector puts vec1.r() Output: 1.7320508075688772 Comment More infoAdvertise with us Next Article Ruby | Vector round() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads 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 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 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 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 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 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 Like