Ruby | Vector size() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 "matrix" # Initialize the vector vec1 = Vector[1, 2, 3] # Prints the size of vector puts vec1.size() Output: 3 Example 2: Ruby # Ruby program for size() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1, 2, 3, 4, 5] # Prints the size of vector puts vec1.size() Output: 5 Comment More infoAdvertise with us Next Article Ruby | Vector size() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads 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 | Struct size() function The size() is an inbuilt method in Ruby that returns the total number of members present in struct. Syntax: struct_name.size() Parameters: The function does not accepts any parameter. Return Value: It returns the integer specifying the members of struct. Example 1: Ruby # Ruby program for size metho 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 | Symbol size function Symbol#size() : size() is a Symbol class method which returns the size/length of the symbol object. Syntax: Symbol.size() Parameter: Symbol values Return: the size/length of the symbol object. Example #1 : Ruby # Ruby code for Symbol.size() method # declaring Symbol a = :aBcDeF # declaring Symbol b 2 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 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 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 zero?() function 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 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 | Set size() function The size() is an inbuilt method in Ruby returns the size of the Set. It returns the number of elements in the set. Syntax: s1_name.size() Parameters: The function does not accepts any parameter. Return Value: It returns the size of the set. Example 1: Ruby # Ruby program to illustrate # the size met 1 min read Like