On Sun, Dec 20, 2020 at 4:45 PM ToddAndMargo via perl6-users <
[email protected]> wrote:
>
> Hi All,
>
> In the following:
>
> Example 3:
>
> class PrintTest {
> has Str $.Msg;
>
> method PrintMsg() {
> print "self = <" ~ self.Msg ~ ">\n";
> print "self = <" ~ self.Str ~ ">\n";
> }
> }
>
> my $x = PrintTest.new(Msg => "abc");
>
> $x.PrintMsg
> self = <abc>
> self = <PrintTest<95224840>>
>
> is "95224840" a C pointer? What is that thing?
>
>
> Many thanks,
> -T
Hi Todd, Looks like you're just returning the Raku pointer. You get the
same result printing "self" with-or-without .Str afterwards:
____
class PrintTest {
has Str $.Msg;
method PrintMsg() {
print "self = <" ~ self ~ ">\n";
print "self = "; dd self;
print "self = "; dd self.WHAT;
put "----";
print "self = <" ~ self.Str ~ ">\n";
print "self = "; dd self.Str;
print "self = "; dd self.Str.WHAT;
put "----";
print "self = <" ~ self.Msg ~ ">\n";
print "self = "; dd self.Msg;
print "self = "; dd self.Msg.WHAT;
}
}
my $x = PrintTest.new(Msg => "abc");
$x.PrintMsg;
____
user@mbook~$ raku ./Todd_classes_1220_2020.p6
self = <PrintTest<140382599051224>>
self = PrintTest.new(Msg => "abc")
self = PrintTest
----
self = <PrintTest<140382599051224>>
self = "PrintTest<140382599051224>"
self = Str
----
self = <abc>
self = "abc"
self = Str
user@mbook~$
If you look at the returns above, calling self with dd (first series) is
actually more informative than stringifying (second series).
HTH, Bill.