summaryrefslogtreecommitdiff
path: root/dictionary.go
blob: a5d81b560b1b20973dad1a814c2fe42102c119b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import (
	"errors"
)

type Dictionary map[string]string

var ErrorNotFound = errors.New("could not find the word you were looking for")

func (d Dictionary) Search(word string) (string, error) {
	definition, ok := d[word]
	if !ok {
		return "", ErrorNotFound
	}

	return definition, nil
}

func (d Dictionary) Add(word, definition string) {
	d[word] = definition
}