-
-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comments for crystal analyzer 1.3
- Loading branch information
1 parent
e1bcb4a
commit e04c8d0
Showing
4 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Pow | ||
|
||
Using the `pow`, `sqrt` or `**` is totally valid and can be neassisary in many situations. | ||
However when wanting a distance in 2d space we can use the [`hypot` method][hypot] which returns the hypotenuse of the x and y lengths. | ||
|
||
```crystal | ||
# Rather than: | ||
Math.sqrt(number ** 2 + another_number ** 2) | ||
# Consider: | ||
Math.hypot(number, another_number) | ||
``` | ||
|
||
[hypot]: https://crystal-lang.org/api/Math.html#hypot%28value1%2Cvalue2%29-instance-method |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Uses the hypot method | ||
|
||
Congratulations, your solution uses the hypot method! | ||
|
||
Your solution uses an efficient way of calculating the distance from the center of a dartboard and that's worth taking a moment to celebrate. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Missing %{method_name} method call | ||
|
||
Like the instructions mention, the purpose of this exercise is to learn about getters and setters. | ||
Manually defining these methods is not inherently bad can lead to code which is more verbose and harder to maintain. |