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 G 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 Like