How to write a Scala method that takes a simple generic type
alvin
June 21, 2015 - 1:20pm
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 19.2, “How to write a Scala method that takes a simple generic type.”
Problem
You’re not concerned about type variance, and want to create a Scala method (or function) that takes a generic type, such as a method that accepts a Seq[A]
parameter.