Hacker News new | ask | show | jobs
by throwaway5959 1101 days ago
Why is map copy "dst, src" vs "src, dst"?
3 comments

Copy operations in Go are normally destination first, source second. This includes builtins like copy() and library functions like io.Copy(). Making it "src, dest" would make this one case the opposite of all the others.

Note that the order mimics variable assignment. You copy an integer with:

    var src, dest int
    dest = src // dest first, src second
I appreciate the consistency.
Thanks, "mimics variable assignment" is a good way to remember it
To match the semantics of dst = copy(src). Multiple languages model operations like this in assignment order.