Last active
April 2, 2023 10:13
-
-
Save dacr/341aa1dcb9c2c7a029ee0f8fdb284be1 to your computer and use it in GitHub Desktop.
scala3 feature examples - transparent traits / published by https://github.com/dacr/code-examples-manager #ada644bc-de96-45f2-8d41-23d58d5708d4/22f28d2e1d9e901b4bc429fd72ac6ba837369e80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// summary : scala3 feature examples - transparent traits | |
// keywords : scala3, tutorial, @testable | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : ada644bc-de96-45f2-8d41-23d58d5708d4 | |
// created-on : 2021-12-25T18:51:10+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
//> using scala "3.1.1" | |
// ----------------------------------------------------- | |
transparent trait TechnicalTrait: | |
def machin() = "machin" | |
trait DomainTrait: | |
def truc() = "truc" | |
// ----------------------------------------------------- | |
@main def go():Unit = | |
val that = new DomainTrait() with TechnicalTrait | |
println("The TechnicalTrait is hidden to the type inference engine !") | |
println("=> DomainTrait INSTEAD OF DomainTrait & TechnicalTrait") | |
println("Better readability in IDE, REPL, Exceptions, ...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment