www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What is the value for D to allow assign bool to char/dchar? For me, it

reply apz28 <home home.com> writes:
     void main()
     {
     	dchar d;
     	d = false;
     	d = true;
     	char c;
     	c = false;
     	c = true;
     }
Aug 07 2021
parent jfondren <julian.fondren gmail.com> writes:
On Saturday, 7 August 2021 at 21:45:09 UTC, apz28 wrote:
     void main()
     {
     	dchar d;
     	d = false;
     	d = true;
     	char c;
     	c = false;
     	c = true;
     }
true is 1 and false is 0. These are valid char and dchar values. Some people and languages are on board with this (like APL, quote: "Ken asked Wolfram why it was that in Mathematica propositions don’t have values 0 and 1 as in APL instead of True and False. Wolfram replied that he had no objections, but the Mathematica implementers were against it."), and some aren't. ```d assert(2 == true+true); assert('a' == "ab"[3 > 5]); assert(2 == iota(5).map!"a>2".sum); ```
Aug 07 2021