On Mon, May 18, 2020 at 4:03 AM Patrick R. Michaud <pmich...@pobox.com> wrote: > > "say $x" is essentially equivalent to "put $x.gist". > > Since Nil is undefined (roughly equivalent to a type object), Nil.gist has a > string value of "Nil" and can be printed. However, attempting to convert Nil > directly into a Str throws an error because that's attempting to stringify an > undefined object. > > You can see this with the following: > > $ rakudo > To exit type 'exit' or '^D' > > say Nil > Nil > > put Nil > Use of Nil in string context > in block <unit> at <unknown file> line 1 > > say Nil.Str > Use of Nil in string context > in block <unit> at <unknown file> line 1 > > put Nil.gist > Nil > > So, the difference in your example is that when the result of s/.../.../ is > Nil (representing a failed Match), C<say> calls .gist on Nil which produces a > printable string, while C<put> attempts to stringify the Nil object directly > and that throws an error. > > Pm >
Thank you very much, Patrick. --Bill.