"Go Switch evaluation order"의 두 판 사이의 차이

(새 문서: ==개요== ;Go Switch evaluation order <source lang='go' run> package main import ( "fmt" "time" ) func main() { fmt.Println("When's Saturday?") today := time.Now().Weekday()...)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
2번째 줄: 2번째 줄:
;Go Switch evaluation order
;Go Switch evaluation order


<source lang='go' run>
<syntaxhighlight lang='go' run>
package main
package main


24번째 줄: 24번째 줄:
}
}
}
}
</source>
</syntaxhighlight>





2020년 11월 2일 (월) 02:48 기준 최신판

1 개요[ | ]

Go Switch evaluation order
package main

import (
	"fmt"
	"time"
)

func main() {
	fmt.Println("When's Saturday?")
	today := time.Now().Weekday()
	switch time.Saturday {
	case today + 0:
		fmt.Println("Today.")
	case today + 1:
		fmt.Println("Tomorrow.")
	case today + 2:
		fmt.Println("In two days.")
	default:
		fmt.Println("Too far away.")
	}
}


2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}