小编Ben*_*enP的帖子

我可以像在C++模板专业化中那样专门化Scala中的函数类型参数吗?

我想编写一个根据其类型参数而行为不同的函数.我想要的一个简单示例如下所示:

def f[Int] = "I'm an int"
def f[Float] = "I'm a float"
def f[Burger] = "You want fries with that?"
Run Code Online (Sandbox Code Playgroud)

这可能在Scala中还是需要某种解决方法?

parameters types scala

5
推荐指数
1
解决办法
885
查看次数

标签 统计

parameters ×1

scala ×1

types ×1