November 04, 2004 opCat request | ||||
---|---|---|---|---|
| ||||
Can we get an operator (or perhaps tweak an existing operator) that does concatentation but allows multiple values or maybe binds left-to-right instead of right-to-left? Suppose I have int[] x; and want to write something like x ~= 1; x ~= 2; x ~= 3; more compactly. I can't use ~= like x ~= 1 ~= 2 ~= 3 since 2 isn't an lvalue. I also can't write something like x ~= 1 ~ 2 ~ 3 since 1 ~ 2 isn't allowed. It would be nice to get some compact way of expressing "append 1,2,3". Maybe a new syntax like x ~= [1,2,3]; that is sugar for the expression "x~=1,x~=2,x~=3". I haven't thought too hard about general solutions but the current situation gets pretty wordy. -Ben |
November 05, 2004 Re: opCat request | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | I think doing array literals would solve the problem. Array literals are on the list for 2.0. |
Copyright © 1999-2021 by the D Language Foundation