2

我想要这样的东西:

[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();

锡兰仿制药可以做到这一点吗?

我怀疑在阅读了关于 Ceylon currying 的内容后应该会出现类似的情况,但我现在无法弄清楚!

4

1 回答 1

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();
于 2014-01-28T01:58:24.967 回答