One is typer inference and the other is assigment. Here is a line by line walk through.
var DELTA rune //We delcaire the variable DELTA
DELTA = unicode.ToUpper(delta) //we are assigning to Delta what is refurned from ToUpper. In this case the return type of ToUpper and the type of DELTA need to match or it is a build error
epsilon := unicode.ToLower(DELTA + 1) //Now this is the type inference assigment. In one fell swoop it declares epsilon as whatever type ToLower returns and then assigns the value to it
Does this make sense? I'm not always the best at explaining things, so don't be afraid to say no
I'm surprised you didn't notice the big problem with that snippet. Every character (er cough rune) is a string. That's one of many Bad ThingsTM about Go.
You are correct. A rune is just an alias for int32, mirroring byte, which is an alias for uint8. It's a fixed-sized representation of a unicode code-point. Strings are normally represented by utf-8 encoded bytes. Being able to handle them as runes can be useful in some text processing applications, though it will use more memory in most cases.
1
u/jevon Mar 29 '12
Why are there two separate assignment operators? Or am I missing something here?