Skip to content

Add default_value() function

Choose a tag to compare

@dnovaes dnovaes released this 07 Aug 18:11
d1149e4
  • Adds new function on the library.:
default_value(value, standard)

If the value is NULL, the result of this function is the standard, otherwise, the result is the value.

This function accept both integer, float, string and boolean types. (C++ overloading for the win)

Some success test samples: ✅

default_value(10, 1)
default_value(NULL, 1)
default_value(10.4, 1.01)
default_value(NULL, 1.01)
default_value("filled", "default")
default_value(NULL, "default")
default_value(false, true)
default_value(NULL, true)

Some failure test samples: 🚫

default_value(1, 4.5)
default_value(4.5, "string")
default_value("string", true)
default_value(true, 1)