4 ms·
And then you have to check that the map you're being given has all the correct keys with the correct typed values. And when you're looking at the code, you see:
by thom 7y ago
And then you have to check that the map you're being given has all the correct keys with the correct typed values. And when you're looking at the code, you see:
function DrawRect(options) {...
Unless you're immediately destructuring it or whatever. I don't think it's _that_ straightforward to compare the two, unless I'm thinking of the wrong languages here.
- Too 7y agoTypescript can specify required keys in a dictionary: function DrawRect(options: { at: Point2D, width: number, height:number}} It will be checked compile time that all keys are provided (unless dict comes from serialized json or something).
- thom 7y agoThat's more verbose than just having arguments though, right?
- Too 7y agoSlightly more verbose but not much. Just having arguments takes you back to square one where you might mix up the order of width and height since nothing is forcing the caller to use named parameters. Perhaps it would be better to have some linter enforcing such things.
- thom 7y agoIt doesn't take you back to square one in languages which enforce named parameters, which I thought we were talking about.