我正在玩 Ceylon,我正在尝试为元组创建别名。以下不起作用:
class MyPair(Integer i, Float f) => [i, f];
class MyPair(Integer i, Float f) => [Integer, Float](i, f);
class MyPair(Integer i, Float f) =>
Tuple<Integer|Float, Integer, Tuple<Float, Float, Empty>>(i, [f]);
class MyPair(Integer i, Float f) =>
Tuple<Integer|Float, Integer, Tuple<Integer|Float, Float, Empty>>(i, [f]);
class MyPair(Integer i, Float f) =>
Tuple<Integer|Float,Integer,Tuple<Float,Float,Empty>>(i, Tuple<Float,Float,Empty>(f, []));
我在前两个上遇到的错误围绕着括号的使用:
Incorrect syntax: missing statement-ending ; at [ expecting statement-ending ;
第二个有两个单独的错误:
的一些变化
Alias parameter distance must be assignable to corresponding class parameter rest: Integer is not assignable to [Integer]
开class MyPair
和
Argument must be a parameter reference to distance
在f
, [f]
, 或元组构造上。
有没有办法做到这一点?