Re: Tip: what is in an array's cell

[email protected] (Elizabeth Mattijsen) Mon, 13 Jul 2026 13:40:52 +0200
Newsgroups perl.perl6.users
Message-ID <[email protected]>
In relation to all this, there's the `.are` method: =
https://docs.raku.org/routine/are

my @a =3D 42, 3.14, "foo";
say @a.are;  # (Cool)


use v6.e.PREVIEW;
my @b =3D 1,2,3;
say @a.are(Int);  # False
say @b.are(Int);  # True


Liz

> On 13 Jul 2026, at 10:13, ToddAndMargo via perl6-users =
<[email protected]> wrote:
>=20
> On 7/13/26 1:09 AM, ToddAndMargo via perl6-users wrote:
>> Hi All,
>> This is a fascinating answer I got back from Chat GPT:
>> -T
>=20
> Chat GPT kept on talking after I thanked him:
>=20
>=20
> One of the things I like about Raku is that its type system
> is very introspective, so you can often ask an object about
> itself. Here are a few other methods you may find useful
> as you explore:
>=20
> say $item.^name;       # Type name, e.g. "Int"
> say $item.WHAT;        # Type object, e.g. (Int)
> say $item.perl;        # Reconstructable representation
> say $item.raku;        # Modern equivalent of .perl
> say $item.gist;        # Human-readable representation
>=20
> And since you're building an array with mixed types, here's a neat =
little debugging loop:
>=20
> for @array.kv -> $i, $item {
>    say "[$i] {$item.raku} ({$item.^name})";
> }
>=20
> which might print:
>=20
> [0] "hello" (Str)
> [1] 42 (Int)
> [2] Person.new (Person)
>=20
> One more Raku feature that surprises people coming from other
> languages: everything is an object. Even an Int, Str, Bool,
> or Nil has methods and type information, so you don't need
> special functions like typeof() or isinstance() from other
> languages.
>=20
> If you keep working with Raku, feel free to ask. It's a language
> with a lot of elegant features that aren't always obvious at
> first, and it's fun to explore them.