-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add code tabs for _overviews/scala3-book/types-union.md #2654
Conversation
### Alternative to Union Types | ||
As shown, union types can be used to represent alternatives of several different types, without requiring those types to be part of a custom-crafted class hierarchy, or requiring explicit wrapping. | ||
|
||
#### Pre-planning the Class Hierarchy | ||
Other languages would require pre-planning of the class hierarchy, like the following example illustrates: | ||
|
||
{% tabs union-preplanning %} | ||
|
||
{% tab 'Scala 3 Only' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% tab 'Scala 3 Only' %} | |
{% tab 'Scala 2 and 3' %} |
{% endtab %} | ||
|
||
{% endtabs %} | ||
|
||
### Alternative to Union Types | ||
As shown, union types can be used to represent alternatives of several different types, without requiring those types to be part of a custom-crafted class hierarchy, or requiring explicit wrapping. | ||
|
||
#### Pre-planning the Class Hierarchy | ||
Other languages would require pre-planning of the class hierarchy, like the following example illustrates: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other languages would require pre-planning of the class hierarchy, like the following example illustrates: | |
In other languages, such as Scala 2, you would require pre-planning of the class hierarchy, like the following example illustrates: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!, just a minor point about "pre planning the class hierarchy" is meant to be a comparison to other languages, so scala 2 can be considered here
Regarding #2481
made on Warsaw Scala Spree