On 09/07/2018 05:08 PM, Curt Tilmes wrote:


On Fri, Sep 7, 2018 at 7:59 PM ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:


     >  From the page you linked to "Coerces the invocant and first
    argument to
     > Str <https://docs.perl6.org/type/Str>, and searches for
    |$needle| in the
     > string starting from |$start|."
     >
> I added to the end "...from $start characters into the string". Does
     > that make it more clear?

    I have no idea what you mean.  I also have no idea what the
    second parameter is either.


     >            say "Hello, World".contains(',', 10);      # OUTPUT:
    «False␤»

    Does "contains" have options for the start, anywhere, or end of the
    string?


In that example, $start is specified as 10, so the search for the ',' starts
10 characters into the string "Hello, World", or at the 'l' at the end
of 'World'.  Since the search starts there, it doesn't find the ',', so
the result is False.  The previous exmple specifies $start at 3, so starts
the search 3 characters into the string "Hello, World", or at the
first 'l', so it does find the ',' and outputs True.

Is there better wording you could suggest for the docs that would better convey
that concept?

Curt


Okay, I get it now.

The second parameter is what position in the string to
start looking for a match.  I was thinking it was a command,
such as uppercase, only one match, etc..

By the way, your explanation did not get me there.  I had to
experiment with it to figure it out.

My big gripe with the documentation is that it is written as
a refresher for those that already know what they are doing.
This is why I am such a good case for spotting things that
do not resonate with beginners.

I am clueless, until I learn.  When I do, I write my own
notes.  I have been trying to remember to write you guys
when the docs fly over my head.

Many thanks,
-T


Suggested wording:

A second parameter can be added after the string to specify
at which position in the string -- starting at zero -- to
start looking for a match.  Delimiter is a comma.

For example, "e" is the fifth character and occupies
position four in the string:

   say "abcdefghij".contains("e", 4); # position 4 is "e"
   True

   say "abcdefghij".contains("e", 5); # position 5 is "f"
   False

Reply via email to