Thread overview
~ ?
Jun 27, 2014
pgtkda
Jun 27, 2014
Ali Çehreli
Jun 27, 2014
pgtkda
Jun 27, 2014
Chris
June 27, 2014
What does this symbol mean in relation to D?

~
June 27, 2014
On 06/26/2014 10:58 PM, pgtkda wrote:
> What does this symbol mean in relation to D?
>
> ~

It can be used in two ways:

1) When used as a unary operator, it means bitwise complement:

    assert(~0xaa55aa55 == 0x55aa55aa);

2) When used as a binary operator, it means concatenation:

    assert("hello" ~ " world" == "hello world");

    auto arr = [ 1, 2 ];
    assert(arr ~ 3 == [ 1, 2, 3 ]);

When used with assignment, it means appending:

    auto arr = [ 1, 2 ];
    arr ~= 3;

    assert(arr == [ 1, 2, 3 ]);

It can also be used in the special function name ~this(), which is the destructor of a struct or a class. (Related functions: 'static ~this()' and 'shared static ~this()')

Ali

[1] http://ddili.org/ders/d.en/bit_operations.html

[2] http://ddili.org/ders/d.en/arrays.html

[3] ddili.org/ders/d.en/special_functions.html

June 27, 2014
On Friday, 27 June 2014 at 06:33:07 UTC, Ali Çehreli wrote:
> On 06/26/2014 10:58 PM, pgtkda wrote:
>> What does this symbol mean in relation to D?
>>
>> ~
>
> It can be used in two ways:
>
> 1) When used as a unary operator, it means bitwise complement:
>
>     assert(~0xaa55aa55 == 0x55aa55aa);
>
> 2) When used as a binary operator, it means concatenation:
>
>     assert("hello" ~ " world" == "hello world");
>
>     auto arr = [ 1, 2 ];
>     assert(arr ~ 3 == [ 1, 2, 3 ]);
>
> When used with assignment, it means appending:
>
>     auto arr = [ 1, 2 ];
>     arr ~= 3;
>
>     assert(arr == [ 1, 2, 3 ]);
>
> It can also be used in the special function name ~this(), which is the destructor of a struct or a class. (Related functions: 'static ~this()' and 'shared static ~this()')
>
> Ali
>
> [1] http://ddili.org/ders/d.en/bit_operations.html
>
> [2] http://ddili.org/ders/d.en/arrays.html
>
> [3] ddili.org/ders/d.en/special_functions.html

Thanks :)
June 27, 2014
On Friday, 27 June 2014 at 05:58:14 UTC, pgtkda wrote:
> What does this symbol mean in relation to D?
>
> ~

~ D means it's about the best language I've come across so far.