in reply to What's the correct and succinct way to refer to object attribute in (informal) description?
With the new class feature, objects are no longer blessed hash references and their attributes (now called fields) can't be accessed without accessors, anyway.
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use 5.039.010; use experimental 'class'; class My { field $x :param :reader; } my $o = 'My'->new(x => 10); say $o->x; # No other way.
Update: Fixed a typo, thanks LanX.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What's the correct and succinct way to refer to object attribute in (informal) description?
by LanX (Saint) on Jun 10, 2024 at 14:15 UTC | |
by choroba (Cardinal) on Jun 10, 2024 at 14:37 UTC | |
by Fletch (Bishop) on Jun 10, 2024 at 14:52 UTC |