|
Scala example source code file (records.scala)
The Scala records.scala source code
trait C {
def f: Int
}
object Test {
type T = C {
def f: Int
def g: String
}
val x: T = new C {
def f = 1
def g = "hello"
}
val y = new C {
def f = 2
def g = " world"
}
val z: T = y
def main(args: Array[String]): Unit = {
assert(x.f+z.f == 3)
assert(x.g+z.g == "hello world")
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala records.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.