我this class在斯卡拉: object Util {
class Tapper[A](tapMe: A) {
def tap(f: A => Unit): A = {
f(tapMe)
tapMe
}
def tap(fs: (A => Unit)*): A = {
fs.foreach(_(tapMe))
我想知道以下是否可能。創建一個接受匿名類型(string,int,decimal,customObject等)的類,然後重載基於類型執行不同操作的方法。例如 class TestClass<T>
{
public void GetName<string>()
{
//do work knowing that the type is a string
}