5 ms·
> we can easily shoot ourselves in the foot. We might mistakenly write Email("hello", "jason", "jason@gmail.com", "body of email"), for example. I would just
by serve_yay 12y ago
> we can easily shoot ourselves in the foot. We might mistakenly write Email("hello", "jason", "jason@gmail.com", "body of email"), for example.
I would just solve that with keyword arguments. Or, in Javascript, have the constructor take an object whose keys are fromAddress, toAddress, etc. (Pretty much the JS/ES5 version of keyword args.)
- xwowsersx 12y agoAnd then if you're missing a key in your object, your program blows up at runtime.
- serve_yay 12y agoIn JS, true. You can't do any of this stuff in JS! :) But I guess my real point was that that seemed like more of an argument against positional parameters than for lots of typing. I like how ObjC handles this, I wish more languages did it that way.