我想要这样的东西:
[String, Integer] values = SomeClass("Hi", 1).values();
[Boolean, Float] others = SomeClass(true, 2.0).values();
// EDIT - should return tuple with same type as the arguments list
[String] strs = SomeClass("Strings").values();
锡兰仿制药可以实现吗?
我怀疑在阅读about currying in Ceylon之后应该有类似的东西,但我现在无法解决这个问题!
答案 0 :(得分:5)
class SomeClass<Args>(Args args)
given Args satisfies Tuple<Anything, Anything, Anything[]> {
shared Args values() => args;
}
[String, Integer] foo = SomeClass(["Hi", 1]).values();
[Boolean, Float] bar = SomeClass([true, 2.0]).values();
[String] baz = SomeClass(["Strings"]).values();