| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
- App.vue
- SFC
- golang
- Dictionary
- reactivity
- Vue.js
- toggle
- CDN
- URL
- graceful shutdown
- container
- method
- channel
- Vue
- goroutine
- go
- goroutines
- cli
- TODO
- emit
- localStorage
- todo-list
- PROPS
- Server
- 행렬
- Refactoring
- component
- Matrix
- map
- websocket
- Today
- Total
목록map (3)
ksundev 님의 블로그
안녕하세요. 이번 포스트에서는 저번 포스트에 이어 Dictionary의 Update, Delete 메서드를 만들어봅시다.# Update()먼저 Search()를 통해 Update하려는 keyword가 있는지 확인해야 합니다. 그리고 적절한 에러처리를 해줍시다.# mydict.govar errCantUpdate = errors.New("can't update non-existing word")// Update a word in the dictionaryfunc (d Dictionary) Update(word, def string) error { _, err := d.Search(word) switch err { case errNotFound: return errCantUpdate case nil: d[..
# type 선언흔히 알고 있는 dictionary 자료형과 같게,"hello" : "안녕""world" : "세상"과 같은 dictionary를 만들어봅시다. # mydict/mydict.gopackage mydict// Dictionary typetype Dictionary map[string]stringtype은 별명(Alias)로 생각하면 됩니다.기존의 자료형 map[string]string을 Dictionary로 부를 수 있게 되는 것입니다. # main.go # Search()이제 key를 통해 단어를 찾는 method를 만들어봅시다.Go에서 type으로 정의한 모든 타입에서 method를 만들 수 있습니다.그리고 go에서 map은 독특하게도 d[word]를 하게되면 return으로 (valu..