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

use ContainsAny() or EqualsAny() in sisimai/string #6

Open
azumakuniyuki opened this issue Sep 19, 2024 · 0 comments
Open

use ContainsAny() or EqualsAny() in sisimai/string #6

azumakuniyuki opened this issue Sep 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@azumakuniyuki
Copy link
Member

ContainsAny()

  • ContainsAny("nekochan", []string{"neko", "nyaan", "cat"}) returns true

EqualsAny()

  • EqualsAny("nekochan", []string{"neko", "nyaan", "cat"}) returns false
  • EqualsAny("neko", []string{"neko", "nyaan", "cat"}) returns true

Use functions above instead of the following code:

text := "nekochan"
list := []string{"neko", "nyaan", "cat"}
test := false
for _, e := range list {
  if strings.Contains(text, e) == false { continue }
  test = true; break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant