Crystal · Lesson 7

Nil safety: String?, if, try and not_nil!

Nil is a type, so String? must be checked before use: narrow with if, chain with try, default with ||, or assert with not_nil!.

Lessons · Crystal · Lesson 7 of 10

Nil safety: String?, if, try and not_nil!

Nil is a type, so String? must be checked before use: narrow with if, chain with try, default with ||, or assert with not_nil!.

Illustration for Crystal
Nil is a type, so String? must be checked before use: narrow with if, chain with try, default with ||, or assert with not_nil!.