Skip to content

Instantly share code, notes, and snippets.

@rabestro
Last active July 17, 2023 08:20
Show Gist options
  • Save rabestro/08be57a2b28b61659eb977ec02aaf634 to your computer and use it in GitHub Desktop.
Save rabestro/08be57a2b28b61659eb977ec02aaf634 to your computer and use it in GitHub Desktop.
Bob - Remark.go
package bob
import (
"strings"
"unicode"
)
type Remark string
func newRemark(remark string) Remark {
return Remark(strings.TrimSpace(remark))
}
func (remark Remark) isSilence() bool {
return remark == ""
}
func (remark Remark) isShouting() bool {
hasLetters := strings.IndexFunc(string(remark), unicode.IsLetter) >= 0
isUpcased := strings.ToUpper(string(remark)) == string(remark)
return hasLetters && isUpcased
}
func (remark Remark) isQuestion() bool {
return strings.HasSuffix(string(remark), "?")
}
func (remark Remark) isExasperated() bool {
return remark.isShouting() && remark.isQuestion()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment