>
>  *c = *c + 1 //why use *c and not just c, based on (c *Count) c is already
> a pointer?
>

In Go (as well as other languages like C) '*' plays two roles. When used
with a type like in "c *Count", it tells you that c is a pointer to a Count
object. When used on a variable, like "*c + 1", it dereferences the
pointer. In other words, "*c + 1" gets the value that "c" is pointing to
and adds one to that value.


> why cast to int, c is already of type int?
>

In this case, c is of type Count, not int. When you define a type in Go,
you're defining a new distinct type, not an alias to the underlying type.
The Count type is distinct from int, even though it's based on int.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA%3DXfu2GL8oLmpjLcoVh8uJu8m4GFJdSh7SfhbvFy%3D9%2BtVwQDQ%40mail.gmail.com.

Reply via email to