What does nil mean in golang?

后端 未结 7 1029
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 06:12

There are many cases using nil in golang. For example:

func (u *URL) Parse(ref string) (*URL, error) {
    refurl, err := Parse(ref)
    if          


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 06:30

    nil is also a value but only difference is- it is empty.

    In Javascript for the un-initialized variable will be undefined. In the same way Golang has nil as default value for all the un-initalized data types.

提交回复
热议问题