Interview at Lang.NEXT

Andrew Edwards via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Jun 4 11:54:01 PDT 2014


On 6/4/14, 2:37 PM, Craig Dillabaugh wrote:
> On Wednesday, 4 June 2014 at 18:14:22 UTC, Adam D. Ruppe wrote:
>> On Wednesday, 4 June 2014 at 18:03:48 UTC, Ary Borenszweig wrote:
> clip
>>
>> void main() {
>>         var a = 10;
>>         var b = "20";
>>         b += a;
>>         b -= 4;
>>         import std.stdio;
>>         writeln(b);
>>
>>         b = [1,2,3];
>>         b[0] *= "5";
>>         writeln(b);
>>
>>         b = var.emptyObject;
>>         b.foo = (var a) {
>>                 foreach(i; 0 .. a.get!int)
>>                         writeln("Hello");
>>         };
>>
>>         b.foo()(5); // would be nice if @property worked!
>> }
>>
>> 26
>> [5, 2, 3]
>> Hello
>> Hello
>> Hello
>> Hello
>> Hello
>>
>>
>> Of course, sometimes the type still matters, like the a.get!int in
>> there, but oh well.
>
> But shouldn't the '26' be '1016'?

That should only occur when the concatenation operator (~) is used, in 
which case the result would be '2006' not '1016'. Since only arithmetic 
operators are used in this example, the result is as expected.


More information about the Digitalmars-d-announce mailing list