JavaFX: concatenation sequences

Is there a standard library function or built-in construct for concatenating two sequences in JavaFX?

The Sequences.concatenate () function is listed here , but it is not visible anywhere in the official API .

Of course, each sequence can be sorted out by inserting values ​​into a new sequence, for example:

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

.. but, of course, something basic, like concatenation, is already defined for us somewhere ..

+3
source share
1 answer

It is very simple, since the sequence cannot be sequential (everything is smoothed), you can do it as follows:

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 this helps.

+5

Source: https://habr.com/ru/post/1736232/


All Articles