From 085d50cd594b16317a8401abf6d5321e56467e2d Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Mon, 13 May 2024 13:50:34 +0200 Subject: [PATCH] Add documentation for complex methods inside Number (#14538) --- src/complex.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/complex.cr b/src/complex.cr index 90c3397e06ce..65fbc9204b59 100644 --- a/src/complex.cr +++ b/src/complex.cr @@ -298,10 +298,12 @@ struct Complex end struct Number + # Returns a `Complex` object with the value of `self` as the real part. def to_c : Complex Complex.new(self, 0) end + # Returns a `Complex` object with the value of `self` as the imaginary part. def i : Complex Complex.new(0, self) end @@ -310,6 +312,9 @@ struct Number other == self end + # [Cis](https://en.wikipedia.org/wiki/Cis_(mathematics)) is a mathematical notation representing `cos x + i sin x`. + # + # Returns a `Complex` object with real part `Math.cos(self)` and imaginary part `Math.sin(self)`, where `self` represents the angle in radians. def cis : Complex Complex.new(Math.cos(self), Math.sin(self)) end