what is D's idiom of Python's list.extend(another_list)?
ag0aep6g
anonymous at example.com
Mon Jun 21 08:40:47 UTC 2021
On 21.06.21 09:02, Mike Parker wrote:
> On Monday, 21 June 2021 at 06:16:15 UTC, mw wrote:
>
>> Ha! great. I didn't know `~` works for both single elements and array!
>
> `~` by itself is the concatenation operator and only works with two
> array operands. `~=` is the append operator and can append arrays or
> single elements.
`~` works just fine with single elements:
void main()
{
import std.stdio;
int[] a = [2, 3, 4];
writeln(1 ~ a ~ 5); /* [1, 2, 3, 4, 5] */
}
More information about the Digitalmars-d-learn
mailing list