Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

jglodek
Copy link
Contributor

@jglodek jglodek commented Dec 7, 2022

Regarding #2481
made on Warsaw Scala Spree

image

### 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' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Copy link
Member

@bishabosha bishabosha left a 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

@julienrf
Copy link
Contributor

Hey @jglodek, thank you for opening this PR.

I went ahead and migrated the file types-union.md in #2768, so I am closing this PR.

@julienrf julienrf closed this Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants