File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import "fmt"
4
+
5
+ func main () {
6
+ // IF
7
+ // If is one of the keyword in conditional statement
8
+ // if block will be executed when the condition is true
9
+
10
+ // ELSE
11
+ // Else block will be executed when the condition are not met/false
12
+
13
+ // ELSE-IF
14
+ // Else-if block will be executed when previous condition are false, and current if is true
15
+
16
+ currentDay := "Senin"
17
+
18
+ if currentDay == "Senin" {
19
+ fmt .Println ("Semangat Pejuang Senin!" )
20
+ } else if currentDay == "Selasa" {
21
+ fmt .Println ("Tetap Semangat walaupun Sekarang Hari Selasa!" )
22
+ } else {
23
+ fmt .Println ("Sekarang bukan Hari Senin maupun hari Selasa!" )
24
+ }
25
+
26
+ // If with Short Statement
27
+ // in Go-Lang we can create if statement with short way
28
+
29
+ if count := len (currentDay ); count > 5 {
30
+ fmt .Println ("Nama hari lebih dari 5 huruf!" )
31
+ } else {
32
+ fmt .Println ("Nama harinya singkat!" )
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments