destroy() Example

Let’s look at an example that demonstrates the use of the destroy() function.

We'll cover the following...

Example

We had designed an XmlElement struct in the constructor and other special functions chapter. We were using that struct for printing XML elements in the format value. Printing the closing tag was the responsibility of the destructor:

struct XmlElement { 
    // ...
    ~this() {
       
...