Is it just me, or is there a problem with page 68 of "The D Programming Language" ? On this page, the author discusses D's syntax of if-else statements and how they nest. He first presents this example:
if(a == b)
if(b == c)
writeln("all are equal!");
else
writeln("a is different from b. Or is that so?");
He then points out that the else will bind to the second if. He then says that, to get the else to bind to the first if, one should use braces like so:
if(a == b) {
if(b == c)
writeln("all are equal!");
else
writeln("a is different from b. Or is that so?");
}
Am I missing the point completely, or would you have to do this:
if(a == b) {
if(b == c)
writeln("all are equal!");
}
else
writeln("a is different from b. Or is that so?");
Top 10 Story IdeasA middle-aged woman discovers a ghost. A woman who is deeply in love is crushed when her fiancé breaks up with her. A talented young man's deepest fear is holding his life back. A poor young boy or girl comes into an unexpected fortune.
Problem-Solution Examples Solution 1: Change the laws to make it more difficult for couples to divorce. Solution 2: Impose a mandatory waiting period on couples before they can get married.
It is indeed an error. The errata for TDPL can be found here: http://www.erdani.com/tdpl/errata/index.php?title=Main_Page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With