Skip to content

Conversation

@joan-miralles
Copy link

No description provided.

Copy link
Member

@JavierCane JavierCane left a comment

Choose a reason for hiding this comment

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

Good one!


import tv.codely.scala_intro_examples.lesson_10_enums_vs_sealed_structures.joan_miralles._

// Try removing one of the cases! That's the power of sealed classes and traits (structures)
Copy link
Member

Choose a reason for hiding this comment

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

Good point!!

thingsToIngest.map {
case IngestibleSealedType(_, maxCalories, _) if maxCalories >= 5000 => "Unhealthy!!! Don't eat them!"
case other: IngestibleSealedType => "Healthy! You can eat a lot of them!"
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice pattern matching!

@JavierCane JavierCane merged commit 2d1e123 into CodelyTV:master Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants