This is valid for many other functions.
get(array,key) or get(key,array) ? find(array,value) or find(value,array) ?
closed as primarily opinion-based by Jerry Coffin, Malachi, Simon André Forsberg, Edward, konijn Jul 2 at 14:31
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.
If your language uses currying, there is another view:
(I'll use Haskell for examples.)
As an example, let's consider
This way, we can compose consecutive maps like
would have been much less composable - try expressing the above example using
This ideas can be seen in many many places. For example, inserting an element into a
which allows us to do things like
So (in languages with currying) it's more convenient to have
I always try and put the "most important" elements at the start, which would be the array in this case. I do this primarily so that my methods have more similar prototypes and I know that the first item in the method is going to be the array/list/etc.
Is much nicer to me than:
An example recently where I've encountered this is when using EntityFramework I had the DataContext in inconsistent positions in the parameter list, this just involves a little more thought than having it as the first parameter all the time.
A side note, if working in a language where you can, it may be nicer to put the method on the array.
Youre question reminds a question I had on the difference between
Both are made for adding elements to a container, but they have a lot of differences. I won't enter in the details of
A difference is in the parameters order.
My conclusion would be: If you design your function to takes multiple arguments, put the new elements on the right. It's common idiom. When lazy, consider the legacy
Long story short, it's a lot easier to remember -and more logical IMO- if one can read
and that still go with
as mentioned by Tyriar in first answer like in
so my answer is :