Related Articles

Related Articles

Ruby | Vector * method
  • Last Updated : 07 Jan, 2020

The * is an inbuilt method in Ruby returns a vector by multiplying vector by x

Syntax: vec1 * x

Parameters: The function does not accepts any parameter.

Return Value: It returns a vector by multiplying vector by x
.



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

#Ruby program for* method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[1, 2]
  
#Initialize the vector
    x
    = 3
  
#prints the new vector
      puts vec1
      * x

chevron_right


Output:

Vector[3, 6]

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#Ruby program for* method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[1, 2, 3]
  
#Initialize the vector
    x
    = 3
  
#prints the new vector
      puts vec1
      * x

chevron_right


Output:

Vector[3, 6, 9]
My Personal Notes arrow_drop_up
Recommended Articles
Page :