3 ms·
Ah, I accidentally lied by trying to reconstruct a vague memory, apologies. Now I'm remembering it in more detail. It wasn't lack of defaults, it was handling
by hakunin 4y ago
Ah, I accidentally lied by trying to reconstruct a vague memory, apologies. Now I'm remembering it in more detail.
It wasn't lack of defaults, it was handling of defaults. Portrayal does a couple of smart things like evaluating defaults in a specific order in the correct context (while still only evaluating once), such that this becomes possible:
keyword :name
keyword :greeting, default: proc { "Hello, #{name}" }
I like being able to do this. (This also works gracefully with subclassing.)
The coercion argument is good, but I'm not a fan of doing it implicitly. (This was the real counter-argument I should've made). I prefer to have a single place where input is entirely processed, such as a `from_params(params)`-style constructor. In that constructor you could either coerce, or do anything else with the input prior to passing it through to `.new`.