2
假设有一个像这样的方法:someAPI(Integer)
。我有一个班groovy隐函数参数类型转换
class MyClass{
int toInteger(){
0 // just for demo. the value will be generated on the fly
}
public <T> T asType(Class<T> c){
0 // just for demo. the value will be generated on the fly
}
}
MyClass myClass
someAPI(myClass as Integer) // OK but it's more like groovy than DSL
someAPI(myClass) // This is what i want, but it gives me an error: method not found.
我该如何让groovy自动将它投给我?当然someAPI()
不是我的修改。
如果答案对您有帮助,请务必“接受”它。 – Renato