inflearn logo
강의

Course

Instructor

GO Language Programming Core Basics Introduction Course, Easy and Quick to Complete

Variables and Constants

짧은 선언으로 변수 여러개를 만들때

240

Youngwook Kim

1 asked

0

a, b := 1, 2
a2, b := 3, 4

b변수 중복선언 에러가 날것 같은데,
b변수에 4가 대입되는 이유는 무었인가요?

 

go

Answer 1

0

niceman

안녕하세요.

짧은 선언(Short Variable Declaration) 질문을 주셨네요.

 

짧은 선언에서는 같은 블록에서 공백이 아닌 새 변수를 다시 선언 가능해요.

단, 짧은 선언에서만 가능합니다. 원본 값은 지워지고 새 할당하겠죠?

 

Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block with the same type, and at least one of the non-blank variables is new. As a consequence, redeclaration can only appear in a multi-variable short declaration. Redeclaration does not introduce a new variable; it just assigns a new value to the original.

고 인터페이스 관련

0

69

2

Join함수 사용이유가 궁금합니다

0

54

1

vscode 설정

0

126

2

arm64

0

202

2

undefined 에러 : UndeclaredImportedName

0

342

1

godoc 에러 관련

0

206

1

package is not in std 오류

0

985

1

맵 예제 코드가 바이러스 검사에 걸려요

0

234

1

for 반복문에서 break와 continue 차이점

0

224

1

후치연산 관련 질문입니다.

0

197

1

package관리에 질문이 있습니다.

0

281

1

go channel 에제에서 질문이 있습니다.

0

192

1

golang 질문

0

310

1

재귀 함수 관련하여 질문이 있습니다.

0

346

1

atom 서비스 종료 관련

0

403

1

vscode 환경설정 업데이트 부탁드립니다

1

403

2

waitGroup.Done을 지연 시키는 방식

0

449

1

첫 번째 예제 질문있습니다.

0

263

1

2개씩 체크가 되는 이유가 궁금합니다.

0

328

1

go 표준 코드 컨벤션이 있나요?

0

825

1

slice에서 make 궁금한 게 있습니다.

1

262

1

import 관리는 어떻게 하나요?

0

317

1

개발환경설정 질문드립니다.

0

486

1

이것도 closure인가요?

0

238

1