728x90
    
    
  불린값은 true 또는 false 를 나타내는 1비트 정수 타입으로, 아래 3가지 연산자가 불린값을 가진다.
| && | and | 
| || | or | 
| ! | not | 
아래의 예를 통해 불린값의 사용법을 알아보자.
1 2 3 4 5 6 7 8 9 10 11  | package main import "fmt" func main() {   fmt.Println(true && true)   fmt.Println(true && false)   fmt.Println(true || true)   fmt.Println(true || false)   fmt.Println(!true) }  | cs | 
실행하면 다음과 같다.
1 2 3 4 5 6  | ~/go/src/golang-book/chapter3# go run main.go true false true true false  | cs | 
다음과 같은 진리표를 보통 사용한다.
| Expression | Value | 
| true && true | true | 
| true && false | false | 
| false && true | false | 
| false && false | false | 
| Expression | Value | 
| true || true | true | 
| true || false | true | 
| false || true | true | 
| false || false | false | 
| Expression | Value | 
| !true | false | 
| !false | true | 
728x90
    
    
  'Season 1 아카이브 > 프로그래밍' 카테고리의 다른 글
| Go 언어 입문 - Control Structures - For (golang-book) (0) | 2018.08.31 | 
|---|---|
| Go 언어 입문 - Variables (golang-book) (0) | 2018.08.28 | 
| Go 언어 입문 - Types - Strings (golang-book) (0) | 2018.08.28 | 
| Go 언어 입문 - Types - Numbers (golang-book) (0) | 2018.08.28 | 
| Go 언어 입문 - Your First Program (golang-book) (0) | 2018.08.27 |