Ruby | Complex abs function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Complex#abs() is a Complex class method which returns the absolute value of the polar form of complex value. Syntax: Complex.abs() Parameter: Complex values Return: absolute value of the polar form of complex value. Example #1 : Ruby # Ruby code for Complex.abs() method # declaring Complex value a = Complex(200) # declaring Complex value b = Complex(-1, 4) # declaring Complex value c = Complex('i') # use of abs() puts "Complex abs form : #{a.abs}\n\n" puts "Complex abs form : #{b.abs}\n\n" puts "Complex abs form : #{c.abs}\n\n" Output : Complex abs form : 200 Complex abs form : 4.123105625617661 Complex abs form : 1 Example #2 : Ruby # Ruby code for Complex.abs() method # declaring Complex value a = Complex(20, 90) # declaring Complex value b = Complex('i') # declaring Complex value c = Complex(100, -500) # use of abs() puts "Complex abs form : #{a.abs}\n\n" puts "Complex abs form : #{b.abs}\n\n" puts "Complex abs form : #{c.abs}\n\n" Output : Complex abs form : 92.19544457292888 Complex abs form : 1 Complex abs form : 509.9019513592785 Comment More infoAdvertise with us Next Article Ruby | Complex abs function K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby Complex-class Similar Reads Ruby | Loops (for, while, do..while, until) Looping is a fundamental concept in programming that allows for the repeated execution of a block of code based on a condition. Ruby, being a flexible and dynamic language, provides various types of loops that can be used to handle condition-based iterations. These loops simplify tasks that require 5 min read Learn Free Programming Languages In this rapidly growing world, programming languages are also rapidly expanding, and it is very hard to determine the exact number of programming languages. Programming languages are an essential part of software development because they create a communication bridge between humans and computers. No 9 min read Ruby Programming Language Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. Ruby is a pure Object-Oriented language developed by Yukihiro Matsumoto. Everything in Ruby is an object except the blocks but there are replacements too for it i.e procs and lambda. The objective of Rubyâs develop 2 min read Ruby on Rails Introduction Ruby on Rails or also known as rails is a server-side web application development framework that is written in the Ruby programming language, and it is developed by David Heinemeier Hansson under the MIT License. It supports MVC(model-view-controller) architecture that provides a default structure f 6 min read Top 30 Scratch Projects in 2024 Scratch is a free programming language developed by MIT where students can create their own interactive stories, games, and animations. Scratch provides a child-friendly platform where kids can learn coding through interactive, fun game projects. It makes programming approachable with its easy-to-us 8 min read Ruby on Rails Interview Questions And Answers Ruby on Rails, often shortened to Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is known for its ease of use and ability to build complex web applications quickly. It was created by David Heinemeier Hansson and was first released in 2004. Now, Over 3. 15+ min read Ruby - String split() Method with Examples split is a String class method in Ruby which is used to split the given string into an array of substrings based on a pattern specified. Here the pattern can be a Regular Expression or a string. If pattern is a Regular Expression or a string, str is divided where the pattern matches. Syntax: arr = s 2 min read Ruby | Data Types Data types in Ruby represents different types of data like text, string, numbers, etc. All data types are based on classes because it is a pure Object-Oriented language. There are different data types in Ruby as follows: NumbersBooleanStringsHashesArraysSymbols Numbers: Generally a number is defined 3 min read Ruby | Case Statement The case statement is a multiway branch statement just like a switch statement in other languages. It provides an easy way to forward execution to different parts of code based on the value of the expression. There are 3 important keywords which are used in the case statement: case: It is similar to 3 min read Ruby Tutorial Ruby is a object-oriented, reflective, general-purpose, dynamic programming language. Ruby was developed to make it act as a sensible buffer between human programmers and the underlying computing machinery. It is an interpreted scripting language which means most of its implementations execute instr 6 min read Like