GNOME Bugzilla – Bug 623856
Vala have no support to concatenate arrays
Last modified: 2018-05-22 13:40:47 UTC
In Vala you can do: var foo = new uint8[10]; foo += 8; which resizes the array and adds a single value. But you can't do the same with an array of the same type: var foo = new uint8[10]; var bar = new uint8[10]; foo += bar; Given error is: error: Incompatible operand error: Assignment: Invalid callback assignment attempt
(In reply to comment #0) > In Vala you can do: > > var foo = new uint8[10]; > foo += 8; > > which resizes the array and adds a single value. > > But you can't do the same with an array of the same type: > > var foo = new uint8[10]; > var bar = new uint8[10]; > foo += bar; > > Given error is: > > error: Incompatible operand > error: Assignment: Invalid callback assignment attempt That would be bad anyway, as the += operator would have two different semantics, appending and concatenating.
In my opinion, the usage of += for appending is wrong anyway. Why not just add a bunch of methods to arrays? .append() and .concat() would do nicely.
*** Bug 760724 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/116.