Skip to content

Commit

Permalink
Merge pull request #589 from lenguyenthanh/implement-functions-inside…
Browse files Browse the repository at this point in the history
…-enum

Implement functions directly inside enum
  • Loading branch information
lenguyenthanh authored Oct 26, 2024
2 parents dab1ddc + e0ba20c commit ffbd182
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 ffbd182

Please sign in to comment.