Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class WalkDistance(val x: Int) extends AnyVal {
- def get: Int = x
- def isEmpty = x < 3000
- }
- final class CarDistance(val x: Int) extends AnyVal {
- def get: Int = x / 1000
- def isEmpty = x >= 3000
- }
- def select(distance: Int) = distance match{
- case WalkDistance(w) => s"I will walk ${w} meters}
- case CarDistance(c) => s"I will drive ${x} km}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement