Bug 610 – Undocumented behaviour: ~ and ~= can now concatenate an array with a single element

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-11-27T09:48:00Z
Last change time
2014-02-15T13:22:15Z
Keywords
spec
Assigned to
bugzilla
Creator
smjg
Blocks
511

Comments

Comment #0 by smjg — 2006-11-27T09:48:44Z
Once upon a time, both sides of a ~ had to be arrays of the same type, even though ~= allowed the rvalue to be a single element to be apppended to an array. Now, ~ can also take a single element on one side. For example: ---------- int[] qwert = [ 2, 3, 4, 5, 6 ]; int[] yuiop = qwert ~ 8; int[] asdfg = 10 ~ yuiop; ---------- However, this capability is not documented, either for ~ or for ~=, as far as I can see.
Comment #1 by matti.niemenmaa+dbugzilla — 2006-12-03T04:09:44Z
Documented for DMD 0.176.