Hacker News new | ask | show | jobs
by tlack 5021 days ago
You know how a lot of jQuery functions take either a string, or a function, or an array of strings, etc? Instead of making those decisions in your code in a series of IF statements, you could use this library and just maintain a "map" of the different argument forms and have this library dispatch the right option.

In Erlang, this is used all the time to make functions that behave differently depending on how they're called - for instance, massaging a binary string into a regular string if the function only expects a regular string.

This is a small tool in a programmer's toolkit, but could be a handy one.