Created
August 12, 2022 03:35
-
-
Save harajune/18b5afbcd70e72838f8f7f0dcc03e074 to your computer and use it in GitHub Desktop.
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 Color { | |
| constructor( | |
| private red: number, | |
| private green: number, | |
| private blue: number | |
| ) { } | |
| public equals(color: Color) { | |
| return this.red === color.red && | |
| this.green === color.green && | |
| this.blue === color.blue | |
| } | |
| } | |
| const appleColor = new Color(255, 0, 0) | |
| const bloodColor = new Color(255, 0, 0) | |
| console.log(appleColor.equals(bloodColor)) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment