Skip to content

Instantly share code, notes, and snippets.

@rabestro
Created July 17, 2023 08:32
Show Gist options
  • Select an option

  • Save rabestro/79f86e7786d53260e288386be5496bdc to your computer and use it in GitHub Desktop.

Select an option

Save rabestro/79f86e7786d53260e288386be5496bdc to your computer and use it in GitHub Desktop.

Revisions

  1. Jegors Čemisovs created this gist Jul 17, 2023.
    21 changes: 21 additions & 0 deletions bob.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    func Hey(remark string) string {
    remark = strings.TrimSpace(remark)

    if remark == "" {
    return "Fine. Be that way!"
    }

    isQuestion := strings.HasSuffix(remark, "?")
    isYelling := strings.ToUpper(remark) == remark && strings.ToLower(remark) != remark

    switch {
    case isQuestion && isYelling:
    return "Calm down, I know what I'm doing!"
    case isQuestion:
    return "Sure."
    case isYelling:
    return "Whoa, chill out!"
    default:
    return "Whatever."
    }
    }