How to parametrize class and implement method depends on type in Scala
This is what I tried. Depends on what does user put into the function I want to add String or Double to new Chunk. package org.apache.spark.h2o.utils import water.fvec.{NewChunk, Frame, Chunk} import water._ import water.parser.ValueString class ReplaceNa[T >: Any](a: T) extends MRTask{ override def map(c: Chunk, nc: NewChunk): Unit = { for (row <- 0 until c.len()) { a match{ case s: ValueString if(c.isNA(row)) => nc.addStr(s) case d: Double if(c.isNA(row)) => nc.addNum(d) } } } } But I got error error: value outputFrame is not a member of Nothing pred.add(new ReplaceNa(3).doAll(1, pred.vec(4)