Auto functions
Common auto functions
Keen will provide an automatic implementation for certain functions.
Just write the function signature without a body and Keen will do the rest.
All of these are implemented by calling a function of the same name on each field and combining the results.
==compares each field (by calling the==function for each field type) and returnstrueif they are all equal.<=>compares each field in declaration order.hashhashes each field in declaration order.tocallstoon each field and creates ajsonobject.
Except for to, it is unsafe to define these functions yourself.
(You can still do so if you mark the body as trusted. See Unsafe code.)
maps depend on those functions being implemented correctly, so it's best to let Keen implement them.
Comparison
You should never define !=, <, >, <=, or >=.
These are defined as generic functions that depend on == and <=>.
If you define <=>, you should always define == too.