-
Exportsscala/scala3 2024. 3. 22. 14:30
class Calculator { val SPEED_OF_LIGHT = 299792458 def energy(mass: Double): Double = mass * SPEED_OF_LIGHT * SPEED_OF_LIGHT } object MyApp { val calculator = new Calculator export calculator.energy def fusionReactor(): Unit = println(energy(0.001)) // export 덕택에 energy 직접 호출 가능 } @main def Main(): Unit = { val mass = 10 MyApp.energy(mass) // export 덕택에 이렇게 사용 가능 }
'scala > scala3' 카테고리의 다른 글
Either using cats and ox (0) 2024.04.04 play-json 에서 scala3 enum 사용하기 (0) 2024.03.29 opaque type (0) 2024.03.22 Function value signature for generics, context functions (0) 2024.03.22 typeclass (0) 2024.03.22