Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • The efficient way to do this would be to store the number in the key field, not the value field; then it's an O(1) lookup. Commented Feb 16, 2015 at 6:16
  • I still don't get it, sorry I'm still learning, how should I implement that? Commented Feb 16, 2015 at 6:17
  • I fixed it with the command case thanks :D Commented Feb 16, 2015 at 15:45
  • Removed my prior comment -- I got that wrong. The Right Thing is actually [[ " ${PhoneNumber[*]} " = *" $MyPhoneNumber "* ]] -- with the whitespace. That's still buggy (prone to false positives) if array values can contain spaces, though, hence the associative array approach both scaling better and being more reliable. Commented Feb 16, 2015 at 16:15