Created
October 5, 2022 20:30
-
-
Save hemalvarambhia/b529eb628e34cff2aea7946b5ee0015f to your computer and use it in GitHub Desktop.
An Example of a Very Basic Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ComplexNumber | |
def initialize(real, imaginary) | |
@real = real | |
@imaginary = imaginary | |
end | |
def to_s | |
"#{@real} + #{@imaginary}i" | |
end | |
end | |
ComplexNumber.new(1, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment