Nim Static Value Conversion

Created on 2022-06-16T20:55:07-05:00

Return to the Index

This card can also be read via Gemini.

A "static" type only accepts parameters with values known at compile time.

Since the value is known at compile time it is possible to use "when" to branch on values at compile time.

Thus values can be converted at compile time which is especially helpful with low overhead bindings.

proc fnord(value: static Sponge): string =
   when value == Yellow:
      return "#yellow"
   elif value == Green:
      return "#green"
   else:
      return "#unknown"