Skip to content

Commit 24b6376

Browse files
seong954tegonSchiele
authored andcommitted
golang about 05_hash_tables (egonSchiele#42)
* recursion_Golang * go_fmt * selection_sort_Golang * rm-golang * selection_sort_Golang * selection_sort_Golang * selection_sort_Golang * dynamic_golang * golang 05_hash_tables 02_check_voter.go * golang 05_hash_tables 01_price_of_groceries
1 parent 542f4ab commit 24b6376

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import "fmt"
4+
5+
var book map[string]float64
6+
7+
func main() {
8+
book = make(map[string]float64)
9+
book["apple"] = 0.67
10+
book["milk"] = 1.49
11+
book["avocado"] = 1.49
12+
fmt.Println(book)
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import "fmt"
4+
5+
var voted map[string]bool
6+
7+
func main() {
8+
voted = make(map[string]bool)
9+
check_voter("tom")
10+
check_voter("mike")
11+
check_voter("mike")
12+
}
13+
14+
func check_voter(name string) {
15+
if voted[name] {
16+
fmt.Println("kick tem out!")
17+
} else {
18+
voted[name] = true
19+
fmt.Println("let tem vote!")
20+
}
21+
}

0 commit comments

Comments
 (0)