Skip to main content

Nil

Sometimes you need to explicitly not return a value, this is when to use nil. It is also what is returned from an empty closure or a closure whose last statement is a let declaration

knot
const empty = nil;
knot
const empty = nil;

Empty Closure

Empty closure expressions evaluate to nil.

knot
const result = {};
knot
const result = {};

Implicit Return

Closures that end in a let declaration implicitly return nil.

knot
const result = {
let foo = "foo";
};
knot
const result = {
let foo = "foo";
};