Skip to content

Commit

Permalink
Implement functions directly inside enum
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Oct 26, 2024
1 parent dab1ddc commit e0ba20c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/src/main/scala/Outcome.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ object Outcome:

enum Points:
case Zero, Half, One
object Points:
extension (p: Points)
def value: Float = p match
case Zero => 0f
case Half => 0.5f
case One => 1f
def show: String = p match
case Zero => "0"
case Half => "1/2"
case One => "1"

def value: Float = this match
case Zero => 0f
case Half => 0.5f
case One => 1f

def show: String = this match
case Zero => "0"
case Half => "1/2"
case One => "1"

import Points.*
type GamePoints = ByColor[Points]
Expand Down

0 comments on commit e0ba20c

Please sign in to comment.