www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ~ ?

reply "pgtkda" <dlang byom.de> writes:
What does this symbol mean in relation to D?

~
Jun 26 2014
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Jun 26 2014
parent "pgtkda" <dlang byom.de> writes:
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 :)
Jun 26 2014
prev sibling parent "Chris" <wendlec tcd.ie> writes:
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.
Jun 27 2014