|
Scala example source code file (sabin2.scala)
The Scala sabin2.scala source code
object Test extends App
{
abstract class Base {
type T
var x: T = _
class Inner {
def set(y: T) = x = y
def get() = x
def print() = println("Hello world")
}
}
object IntBase extends Base { type T = Int }
object StringBase extends Base { type T = String }
val a : Base#Inner = new IntBase.Inner
val b : Base#Inner = new StringBase.Inner
a.print() // OK
b.print() // OK
a.set(b.get()) // Error
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala sabin2.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.