2

I have a domain of strings and I want to test for an elements. The find seems to be what I want, but it's giving me an error.

var names: domain(string);
names += "bob";
if !names.find("bob") {
  writeln("Where is Bob?")
}

produces an error

error: illegal access of iterator or promoted expression
Brian Dolan
  • 3,086
  • 2
  • 24
  • 35

1 Answers1

3

To check for membership within a domain, you want to use domain.member():

if !names.member("bob") {
  writeln("Where is Bob?")
}

As for your original example, there is no domain.find(), so your original example is actually getting promoted to string.find() on each element of the domain. #8450 describes this in more detail.

ben-albrecht
  • 1,785
  • 10
  • 23