Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: link to universal operators page

...

I then installed this ruleset in a pico named–you guessed it–name. Then, I did some experiments using the Testing tab, having turned on logging in the Logging tab. When it came time to enter a value to test the name:name event, I used, of course, "name" as that value.

...

The function will be called, before the Universal Operator defaultsTo() is applied. At that point in time, the name name is bound to the global function, and so that function is called with itself as the argument! And, it will return itself as the result (because a function is considered "truthy"). When the event attribute named name is provided (i.e. is not null), defaultsTo() will not use it and will not produce output in the logs, but will just return the provided value. Notice that after this, the provided value will be bound to the name name. This shadows the name of the global function, which will no longer be available within this rule. Probably not a good practice.