hankache / rakuguide

The Raku Guide

Home Page:https://raku.guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merge code and output to make examples easier to read

uvtc opened this issue · comments

I think this:

my Int $var;
say $var.WHAT;
my $var2;
say $var2.WHAT;
$var2 = 1;
say $var2.WHAT;
$var2 = "Hello";
say $var2.WHAT;
$var2 = True;
say $var2.WHAT;
$var2 = Nil;
say $var2.WHAT;

Output

(Int)
(Any)
(Int)
(Str)
(Bool)
(Any)

Would be easier to read as:

my Int $var;
say $var.WHAT;   # (Int)
my $var2;
say $var2.WHAT;  # (Any)
$var2 = 1;
say $var2.WHAT;  # (Int)
$var2 = "Hello";
say $var2.WHAT;  # (Str)
$var2 = True;
say $var2.WHAT;  # (Bool)
$var2 = Nil;
say $var2.WHAT;  # (Any)

Also, in places where you want to say, "evaluates to", #=> would work. For example,

my @animals = ['camel','llama','owl'];
say @animals;

(where, it's output is not currently shown) could just be

my @animals = ['camel','llama','owl'];
#=> [camel llama owl]

(where the output is shown and included right next to the code that generated it).

@uvtc I updated the introspection example as you proposed.

Nice. :)