我想写一个Java2Go生成器,但是我发现很难表达多态性(例如:形式arg是Base类,而真正的arg是Sub类),我如何在Go中表达吹代码?
class Base{
public int i;
}
class Sub extends Base{
}
class Test{
public static int test(Base base){
base.i = 99;
return base.i;
}
public static void main(String [] args){
Sub sub = new Sub();
System.out.println(test(sub));
}
}
扬帆大鱼
婷婷同学_
相关分类