Search code examples
red-lang

How did `find` actually locate a character in a string, when it was passed a string, not a character?


I was surprised to note that find "rspq" "q" actually found q in the series. The reason it surprised me is that the string "rpsq" is a series of characters and I expected to have to specify "q" as a character not as a string.

This leads to 2 questions for me: 1. how do I specify the character q in Red? 1. why did the search succeed even though I passed in a string not a character?


Solution

    1. Consult the official reference documentation.
    2. Functions in Red are highly polymorphic. find can either search for a given element or a first occurence of sub-series.