今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Constants
- [Instructor] Go supports constants which are declared with the cons keyword. Constants in Go must be strings, booleans, numerics, or runes, the last being what you'll typically recognize as the single character value in a single quotes. We'll declare pi and give it a value. Pi's type will be inferred as a float. We'll also declare a rune, and though not necessary, be explicit about its type as a rune. Let's print out these constants and their types using the func dot print F with the %V and %T verbs to show the value and type of the constant pi, respectively. While we're at it, we'll also print the rune a. Before we run the program, let's sneak in the Unicode packages is letter function to confirm that the rune a is indeed a letter. We can see that VS code or Codespaces is importing my packages for me automatically, as I make use of them. Let's now run our program and check our output. As expected, our pi is of a floating…