string contains
# help
z
After reading the docs at https://docs.toit.io/language/strings I don't understand the way to do string contains. In Python:
Copy code
if "foo" in "foobar":
    print("String was contained")
Ruby:
Copy code
if my_string.include? "foo"
Is there a way to check to see if a string contains a substring?
k
https://libs.toit.io/core/string/class-string#contains(3%2C0%2C0%2C)
z
thanks! @kasperl
k
"foobar". contains "foo"
(I think)
z
yep, that worked.
k
👍
e
Also useful:
Copy code
index := haystack.index_of needle
  // If it's not there, then index is -1:
6 Views