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

Scala example source code file (type-diagnostics.scala)

This example Scala source code file (type-diagnostics.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

calculator, calculator, hello, int, list, list, ordered, ordered, partialinfer, set, setvsset, string, string, tparamconfusion

The Scala type-diagnostics.scala source code

object SetVsSet {
  case class Calculator[+T](name: String, parameters: Set[String])
  val binding = Map.empty[String, String]
  def f = Calculator("Hello", binding.keySet: collection.Set[String])
}

object TParamConfusion {
  def strings(xs: List[String]) = xs
  
  def f1[a <% Ordered[a]](x: List[a]) = {
    def f2[b >: List[a] <% Ordered[b]](x: List[a], y: b): Int = {
      def f3(xs: List[a], ys: List[a]) = -1
      y match { case y1: List[a] => f3(x, y1) }
    }
  }
  
  def f2[String](s: String) = strings(List(s))
}

object PartialInfer {
  val f = { case 5 => 10 }
}

Other Scala examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.