Use Sealed Classes#2
Open
nschwermann wants to merge 1 commit into
Open
Conversation
* Refactor to sealed classes * Update docs * No longer need brackets for adding two troll number expressions many-one + many-one = many-many-two * Simplify eval on expression. * Officially geeking out. Numbers greater than 16 should be lots and lots not many and many according to wiki https://discworld.fandom.com/wiki/Troll#:~:text=Trolls%20have%20a%20numeral%20system,to%20those%20of%20the%20others.
Owner
|
This is a great improvement over my implementation. However I'm not sure how to deal with it because my implementation is described in the article and by changing the implementation we kind of lose the connection between them. What do you think about adding another kotlin folder instead, calling it kotlin-with-sealed-classes or something like that? |
Author
|
Can you update your article so the link points to a specific commit? Then
you can write a follow-up about your improvements and what you've learned
if you like :) if you have any questions to get a deeper understanding of
the changes I'm happy to help.
…On Sun, Dec 6, 2020, 1:44 AM Uzi Landsmann ***@***.***> wrote:
This is a great improvement over my implementation. However I'm not sure
how to deal with it because my implementation is described in the article
<https://medium.com/webstep/how-trolls-count-in-kotlin-80465b2019c0> and
by changing the implementation we kind of lose the connection between them.
What do you think about adding another kotlin folder instead, calling it
kotlin-with-sealed-classes or something like that?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGZSBJJRJTXGZZAQJVSLTLSTMY4JANCNFSM4UOTJNJQ>
.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor to sealed classes - This keeps invalid TrollNumbers from being created and is also a perfect use case and example of creating algebraic data types using sealed classes in Kotlin
Update docs
No longer need brackets for adding two troll number expressions
many-one + many-one = many-many-two
Officially geeking out. Numbers greater than 16 should be lots and lots not many and many according to wiki
Discword Wiki - TrollNumbers