title: Specifying methods to call on an unknown generic type
body: <p>Suppose I have code like the following:</p>
  
  <pre><code>abstract class GenericType[T]{
      val someSeq: Seq[T]
  
      def list() = for(item &lt;- someSeq) println(item)
  }
  
  class ConcreteType extends GenericType[Int] {
      val someSeq = Seq(1, 2, 3)
  }
  
  object MyApp {
      def main(args: Array[String]) {
          val ct = new ConcreteType
          ct.list()
      }
  }
  </code></pre>
  
  <p>That simply prints out 1 2 3 (on separate lines). But suppose that I wanted to create an instance of generic type that calls some method of <code>T</code>, instead. For example, suppose I wanted to call an integer's <code>max</code> method. How would I specify the method to call?</p>
  
  <p>I presume that somehow I could create a value in the abstract class that contains the method to call on each <code>item</code> and specify that method in the concrete class.</p>
  
  <p>So in other words, I want to end up with something like:</p>
  
  <pre><code>abstract class GenericType[T]{
      val someSeq: Seq[T]
      val methodToCall: ???
  
      def list() = for(item &lt;- someSeq) println(item.methodToCall)
  }
  
  class ConcreteType extends GenericType[SomeType] {
      val someSeq = Seq(1, 2, 3)
      val methodToCall = ???.max(_, 2)
  }
  </code></pre>
  
  <p>And would expect <code>main</code> to then print out 2 2 3 (ie, the result of <code>for(item &lt;- someSeq) println(item.max(_, 2))</code>).</p>