Skip to content

Commit

Permalink
test if else
Browse files Browse the repository at this point in the history
test if else
  • Loading branch information
tainguyenbp committed May 31, 2024
1 parent 73bd5ed commit 658a317
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hacking-go/learn04/if/if2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import "fmt"

func main() {
if var1 := 100; var1 > 20 {
fmt.Println("Value inside if:", var1)
}
// Cannot use the variable var1 here

}
13 changes: 13 additions & 0 deletions hacking-go/learn04/if/ifelse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import "fmt"

func main() {
if var1 := 10; var1 > 20 {
fmt.Println("Value inside if:", var1)
} else {
// Can use var1 here
fmt.Println("Value inside else:", var1)
}

}

0 comments on commit 658a317

Please sign in to comment.