Ruby | Vector to_a() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 "matrix" # Initialize the vector vec1 = Vector[1, 2, 3] # Prints the array puts vec1.to_a() Output: 1 2 3 Example 2: Ruby # Ruby program for to_a() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1, 2, 3, 4, 5] # Prints the array puts vec1.to_a() Output: 1 2 3 4 5 Comment More infoAdvertise with us Next Article Ruby | Vector to_a() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads 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 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 to_matrix() function The to_matrix() is an inbuilt method in Ruby returns the matrix of single column with elements of vector. Syntax: vec1.to_matrix() Parameters: The function accepts no parameter Return Value: It returns the matrix of single column with elements of vector Example 1: Ruby # Ruby program for to_matrix() 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 | Time to_a() function Time#to_a() is a Time class method which returns the string which returns a ten-element array of values for time. Format [sec, min, hour, day, month, year, wday, yday, isdst, zone] Syntax: Time.to_a() Parameter: Time values Return: a ten-element array of values for time. Example #1 : Ruby # Ruby cod 2 min read Like