Scala 定义不需要规范的模板方法
我想在Scala中声明一个方法,它将有一个来自Spark MLlib的ProbabilisticClassifier类型的参数。这是github()的签名: 不行。相反,我们应该写作Scala 定义不需要规范的模板方法,scala,user-defined-functions,apache-spark-mllib,scala-template,Scala,User Defined Functions,Apache Spark Mllib,Scala Template,我想在Scala中声明一个方法,它将有一个来自Spark MLlib的ProbabilisticClassifier类型的参数。这是github()的签名: 不行。相反,我们应该写作 var x = method[Vector, RandomForestClassificationModel](RandomF); 有没有办法定义这个方法来避免它的每个调用规范 def method[ FeaturesType, M <: ProbabilisticClassifica
var x = method[Vector, RandomForestClassificationModel](RandomF);
有没有办法定义这个方法来避免它的每个调用规范
def method[
FeaturesType,
M <: ProbabilisticClassificationModel[FeaturesType, M]
] (c: ProbabilisticClassificationModel[FeatureType, M]): M = {...}
var x = method(RandomF);
var x = method[Vector, RandomForestClassificationModel](RandomF);