Go language Learning nine-String ()

Source: Internet
Author: User
Package Mainimport "FMT" Func Main () {/* A type if a string method that defines a pointer receiver: func (P *type) string () string {} is called when printing this type of pointer, when the value of this type is printed Will not be called. */var x xint = 123fmt. PRINTLN (x)//123FMT. PRINTLN (&x)//Can not print xint point./* a type if the value recipient's String method is defined: Func (P Type) string () string {} Prints the value and pointer of the variable of this type will be called * /var y yint = 123fmt. Println (y)//can not print Yint.fmt.Println (&y)//can not print yint.} Type Xint intfunc (x *xint) string () string {return "can not print Xint point."} Type Yint intfunc (x Yint) string () string {return "can not print Yint."}

Go language Learning nine-String ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.