Open In App

Ruby | Numeric rectangular() function

Last Updated : 19 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The rectangular() is an inbuilt method in Ruby returns an array which consists of a real and an imaginary number.

Syntax: num.rectangular()

Parameters: The function needs the number whose real and imaginary part is returned.

Return Value: It returns an array which consists of a real and an imaginary number.

Example 1:




# Ruby program for rectangular()
# method in Numeric
  
# Initialize a number 
num = Complex(10, 6)
  
# Prints the rectangular part
puts num.rectangular()


Output:

10
6

Example 2:




# Ruby program for rectangular()
# method in Numeric
  
# Initialize a number 
num = Complex(18, 16)
  
# Prints the rectangular part
puts num.rectangular()


Output:

18
16

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads