News for hackers. Stuff that matters.
Re:Things I Wish Someone Had Told Me About Go by latch on Monday March 11, 2013 @01:08PM (#5358080)
If you write that in C#, and declare the argument as "ref User u", it'll print "newName". Which is what I think pass by reference is. Java and Go (and C) are pass by value.

When I started learning Go, I kept seeing people talk about pass by reference, so I assumed it really did pass by reference (despite being uncommon). I was surprised to find out that it does pass by value.

Re:Things I Wish Someone Had Told Me About Go by drivebyacct2 on Monday March 11, 2013 @01:11PM (#5358095)
Well, like I said, I've never seen anyone claim Go as pass-by-reference. That having been said, the spec refers to slices and maps as "reference types" but it doesn't mean they're pass by reference. They're still passed as a pointer, you just don't see it.

You're correct about the "ref" keyword in C#, when used for the arg and parameter, it causes the function or method to act on the same chuck of memory as the alias represented in the caller.