Go syntax features in my eyes

Source: Internet
Author: User

Since C #/JavaScript/C ++/Python/Lua/Action Script has been used for many times, I am familiar with all the C series syntaxes;

When you look at the language, it will certainly be analogous to the C series. Then, let's summarize the uniqueness of the Go language to C.

  • When declaring variable constants and function types, put them behind the name. This is a bit similar to as3, except to remove the colon when as3 declares the variable.
  • Only struct and functions can be defined. There is no such thing as a class. That is to say, a function and a member variable cannot be put together, which is the same as C.
  • If, for, and other clause conditions, do not need to use arc wrap, this is the same as python2
  • The loop clause only uses for. However, this for clause is special. You can use two semicolons in it, or directly convert any condition without changing to while (true ).
  • Like python, a function can return multiple values, and declare variables and assign values to multiple values in a row.
  • Like python, many system functions are basically the same. Len gets the length of arrays and character characters, range can get the iterator of the loop, and make can generate a map instance. For example, M: = make (Map [String] INT)
  • Like python, there is a delete, but the delete (M, "Answer ")
  • Like python, it has built-in strings, arrays, and maps.
  • What's more, this built-in map is actually a STD: multimap. If you call the same key once, it will become the following

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.