go-analyzer/tests/test_multiple_declaration.txt

21 lines
811 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main;
func test() {
a := 1; // декларация одной переменной (число)
a := "test"; // декларация одной переменной (строка)
a, b := 1, 2; // декларация нескольких переменных (целые литералы)
a, b := b, a; // swap
a, b := "hello", "sailor"; // декларация нескольких переменных (строковые литералы)
a, b, c, d := "hello", 2, 3.123, true; // декларация нескольких переменных (всякое)
// цикл с множественной декларацией и множественным присвоением
for k, l := 0, 10; k < l; k, l = k+1, l-1 {
}
}
func main() {
test();
}