FAQ
type Server interface {
Name() string
Handle(method, params string) *Response
}

var _ ipc.Server = &CenterServer{}

type CenterServer struct {
servers map[string] ipc.Server
players []*Player
rooms []*Room
mutex sync.RWMutex
}

=====================================

in the statement
var _ ipc.Server = &CenterServer{}
what dows the "_" mean???

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Jul 11, 2013 at 2:37 am

    On Thu, Jul 11, 2013 at 12:31 PM, Xiaomin Luo wrote:

    in the statement
    var _ ipc.Server = &CenterServer{}
    what dows the "_" mean???
    Questions like these are usually best handled by reading the spec.
    http://golang.org/ref/spec#Blank_identifier

    It means that the assignment is to no variable. Indicating that the
    assignment is to a variable that you're never going to want to use.
    This is often done just to check that a value is assignable to a variable
    of a specific type.
    in this case, it's checking if an &ipc.CenterServer can be assigned to an
    ipc.Server ie. whether it satisfies the interface.




    --
    =====================
    http://jessta.id.au

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Xiaomin Luo at Jul 11, 2013 at 2:48 am
    I see. I was just mixuped,
    I supposed it to see like this" var _, ipc.Server = ..." with a "," behind
    "_"
    however, I forgot that ipc.Server is a type
    thanks

    在 2013年7月11日星期四UTC+8上午10时37分03秒,Jesse McNelis写道:
    On Thu, Jul 11, 2013 at 12:31 PM, Xiaomin Luo <shawn...@gmail.com<javascript:>
    wrote:
    in the statement
    var _ ipc.Server = &CenterServer{}
    what dows the "_" mean???
    Questions like these are usually best handled by reading the spec.
    http://golang.org/ref/spec#Blank_identifier

    It means that the assignment is to no variable. Indicating that the
    assignment is to a variable that you're never going to want to use.
    This is often done just to check that a value is assignable to a variable
    of a specific type.
    in this case, it's checking if an &ipc.CenterServer can be assigned to an
    ipc.Server ie. whether it satisfies the interface.




    --
    =====================
    http://jessta.id.au
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 11, '13 at 2:31a
activeJul 11, '13 at 2:48a
posts3
users2
websitegolang.org

2 users in discussion

Xiaomin Luo: 2 posts Jesse McNelis: 1 post

People

Translate

site design / logo © 2021 Grokbase