小编joh*_*ith的帖子

如何在python中定义命名空间?

似乎python确实有名称空间.但我能得到的是人们告诉我什么名称空间或范围.那么如何在python中定义命名空间?我只需要语法(并举例说明会更好).

python

7
推荐指数
1
解决办法
3967
查看次数

groovy隐式函数参数类型转换

假设有一个这样的方法:someAPI(Integer)。我还有课

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.
Run Code Online (Sandbox Code Playgroud)

我怎样才能让groovy自动为我投射它?当然someAPI()不是我可以修改的。

groovy

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

标签 统计

groovy ×1

python ×1