Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Latest commit

 

History

History
78 lines (54 loc) · 1.73 KB

Notation.md

File metadata and controls

78 lines (54 loc) · 1.73 KB

Notation

Inspired by SO answer and its source - thesis Evaluierung des Einsatzes von Scala bei der Entwicklung für die Android-Plattform by Meiko Rachimow.

Inheritance

trait TraitB; trait TraitC; trait TraitDBase

abstract class ClassABase
class ClassA extends ClassABase with TraitB with TraitC
trait TraidD extends TraitDBase
trait TraitI { self: TraitC => }

Mutability

class ClassK(val count: Int, cache: Int)

class ClassJ(var field: Option[Int])

class ClassL { lazy val sum = (1 to 1000000).sum }

Object

class ClassF {
	import ClassF._
	
	def instanceMethod: Double = 0
}

object ClassF {
	def staticMethod: ClassF = null
}

Types

Please remember that most of following language properties are not supported by Dia2Scala. This sub-page is about notation, not currently supported features (it might be implemented in future though).

abstract class ClassG[T <: Any] {
  def process: T
}

object ClassG {
  def method[S](x: Seq[S]): S = x.head
}

class ClassGChild extends ClassG[Int] {
  def process = 2
}

class ClassH[T <: { def op: String }](val data: T) {
  def applyOp: String = data.op
}

println(ClassG.method(Seq("a", "b")))
println(new ClassGChild().process)
println(new ClassH(new { def op = "Whoo" }).applyOp)