alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (t1391.scala)

This example Scala source code file (t1391.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

a, a, ab, b, b, list, nanb, ta, ta, tb, tb

The Scala t1391.scala source code

package sandbox

 class hierarOverload {

 /*
  * Template structure - using abstract types.
 */
   trait AB {
     type TA <: A
     type TB <: B

     protected trait A {
       val entities : List[TB]
     }

     protected trait B {
       var group : TA
     }
   }

 /*
  * Template instantiation in an object to ease use and globally define
 abstract types
 */
   object NAnB extends AB {
     type TB = nB
     type TA = nA

     class nA extends A {
       val entities = List[nB]()
     }

     class nB extends B {
       var group = new nA
     }
   }

   def foo () {
     val t = new NAnB.nA
     println(t)
   }

 }

Other Scala examples (source code examples)

Here is a short list of links related to this Scala t1391.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.