You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my @h is default([])
[]
@h[0].push: 3
[3]
@h
[]
@h[0]
[3]
my %h is default({})
{}
%h<a><b> = 3
3
%h
{}
%h<a>
{b => 3}
The array/hash variable's default is an empty array/hash literal. If an element is autovivified, it can be accessed directly, but isn’t findable from the variable.
On 2017-09-09 19:53:53, tomentiruran@gmail.com wrote:
my @h is default([])
[]
@h[0].push: 3
[3]
@h
[]
@h[0]
[3]
my %h is default({})
{}
%h<a><b> = 3
3
%h
{}
%h<a>
{b => 3}
The array/hash variable's default is an empty array/hash literal. If
an element is autovivified, it can be accessed directly, but isn’t
findable from the variable.
On Sat, 09 Sep 2017 19:53:53 -0700, tomentiruran@gmail.com wrote:
my @h is default([])
[]
@h[0].push: 3
[3]
@h
[]
@h[0]
[3]
my %h is default({})
{}
%h<a><b> = 3
3
%h
{}
%h<a>
{b => 3}
The array/hash variable's default is an empty array/hash literal. If
an element is autovivified, it can be accessed directly, but isn’t
findable from the variable.
While I suspect this can be fixed (and is missing setup of the auto-viv callback on the codepath for setting up a default), note that `is default` is a trait, it is evaluated at compile time. Thus there is one single array that will be shared globally and assigned into all elements, which probably isn't what you wanted.
Migrated from rt.perl.org#132053 (status was 'open')
Searchable as RT132053$
The text was updated successfully, but these errors were encountered: