Pattern Maching

Were it so easy..

It is not that different!

In the basics, we read that Ashen types are immutable, so how is null safety done? how do I.. un-null something?

Checking if something is null, and if not generating a new variable:

var nullContent : String? = fsReadText("/banana.txt");

if (nullContent then ctn) {
      // ctn is nullContent but of type String, only if nullContent is not null!
}

// If you do not want to manually handle nullables, you can alternative call .force() on any null value to make
// your program crash immediately in case it is null.

I have a tree of Nodes, but how do I know if a Node is a Text node or HTML Element?

And there is Ashen's instanceof operator!

var node = parseDocument(....);
  
if (node instanceof HTMLElement) {
      // node is an HTMLElement! cast like this:
    var element = node as HTMLElement;
}

// hmm.. thats a lot, but fear no evil! the snippet below does the same thing:

if (node instanceof HTMLElement then element) {
      // element is of type HTMLElement!
}