lines.contains... is really short for: lines.Str.contains... Do you then understand what's going on?
> On 28 Jan 2023, at 21:41, William Michels via perl6-users > <perl6-users@perl.org> wrote: > > Some more examples: > > ~$ raku -e 'put "1\n2\n3";' | raku -e 'lines.contains(/ \h /).put;' > True > ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ \h /).put;' > False > ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ 12 /).put;' > False > ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ "1 2" /).put;' > False > ~$ > > So what I don't understand is how`.contains` coerces `\0` null-separated > strings to a `Str` without whitespace, but coerces `\n` newline-separated > strings to a `Str` with whitespace. Furthermore, it seems that `\0` > null-separated strings are correctly processed so that concatenation > artifacts such as "12" string or "1 2" string are not produced. > > And if `.contains` can coerce `\0` null-separated strings to a Str without > whitespace, can't it do the same for `\n` newline separated strings? What am > I missing? > > Best Regards, Bill. > > PS. Typo: of course, that title should read 'horizontal', not 'horizonal'. > > On Thu, Jan 26, 2023 at 3:40 PM William Michels <w...@caa.columbia.edu> wrote: > Thanks Sean. > > Made some progress. I like this result better: > > ~$ raku -e 'put "1\n2\n3";' | raku -e 'lines.map(*.contains(/ \h /)).put;' > False False False > > Thx, Bill. > > On Thu, Jan 26, 2023 at 12:12 PM Sean McAfee <eef...@gmail.com> wrote: > On Thu, Jan 26, 2023 at 12:05 PM William Michels via perl6-users > <perl6-users@perl.org> wrote: > ~$ raku -e 'put "1\n2\n3";' | raku -e 'put lines.contains(/ \h /) ?? True !! > False;' > True > > lines() returns a Seq. The contains method for a Seq coerces its argument to > a Str and calls contains on that Str. And: > > $ raku -e 'put "1\n2\n3"' | raku -e 'put lines.Str' > 1 2 3 > > There's your horizontal whitespace. >