guild icon
Toit
#string contains
Thread channel in help
z3ugma
z3ugma 01/07/2023 05:42 PM
After reading the docs at https://docs.toit.io/language/strings I don't understand the way to do string contains.

In Python:

if "foo" in "foobar": print("String was contained")

Ruby:
if my_string.include? "foo"

Is there a way to check to see if a string contains a substring?
z3ugma
z3ugma 01/07/2023 05:45 PM
thanks! @bitphlipphar
bitphlipphar
bitphlipphar 01/07/2023 05:48 PM
"foobar". contains "foo"
bitphlipphar
bitphlipphar 01/07/2023 05:48 PM
(I think)
z3ugma
z3ugma 01/07/2023 06:01 PM
yep, that worked.
bitphlipphar
bitphlipphar 01/07/2023 06:49 PM
:👍:
erikcorry_arbat
erikcorry_arbat 01/08/2023 08:56 PM
Also useful:
index := haystack.index_of needle // If it's not there, then index is -1:
8 messages in total