Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isogram: false positive on variable declaration with zero value #76

Open
tehsphinx opened this issue Jan 22, 2019 · 0 comments
Open

isogram: false positive on variable declaration with zero value #76

tehsphinx opened this issue Jan 22, 2019 · 0 comments

Comments

@tehsphinx
Copy link
Member

False positive on solution: https://exercism.io/mentor/solutions/6356bab9214544fe85b37b0c646c183b?iteration_idx=3

package isogram

import (
	"strings"
	"unicode"
)

//IsIsogram returns true if string is isogram
func IsIsogram(word string) bool {
	wordUpper := strings.ToUpper(word)
	for i := 0; i < len(wordUpper); i++ {
		if unicode.IsLetter(rune(wordUpper[i])) {
			if strings.Count(wordUpper, string(wordUpper[i])) > 1 {
				return false
			}
		}
	}
	return true
}

Wrong output:

  • If you're declaring a variable which can be initialized with its zero value, then var s string is more idiomatic than an assignment: s := "".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant