开发者

JavaFX: concatenating sequences

Is there a standard library function or built-in construct to concatenate two sequences in JavaFX?

Here a Sequences.concatenate() function is mentioned, but it is nowhere to be seen in the offici开发者_如何学Pythonal API.

Of course one could iterate over each sequence, inserting the values into a new sequence e.g:

function concatenate(seqA: Object[], seqB: Object[]) : Object[] {
    for(b in seqB) insert b into seqA;
    seqA;
}

..but surely something as basic as concatenation is already defined for us somewhere..


It is very simple, since there cannot be sequence in sequence (it all gets flattened), you can do it like this:

var a = [1, 2];
var b = [3, 4];
// just insert one into another
insert b into a;
// a == [1, 2, 3, 4];

// or create a new seq
a = [b, a];
// a == [3, 4, 1, 2];

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜