当原始变量具有默认强制时,有没有办法访问混合组件? [英] Is there a way to access mixed-in components when the original variable has a default coercion?
本文介绍了当原始变量具有默认强制时,有没有办法访问混合组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在这种情况下:
my @list = (2,) but "bar";
put @list.Str «2»
似乎没有办法访问栏"成分.我错过了什么吗?例如,使用 Set
There does not seem to be a way to access the "bar" component. Am I missing something? Same will happen, for instance, with Set
my @list = (2,3) but Set(4,5);
put @list.Set; # OUTPUT: «3 2»
推荐答案
赋值是一个复制操作,所以:
Assignment is a copying operation, so:
my @a = something;
在@a
中创建一个Array
,迭代something
,并将每个元素存储在@a
中.如果改为使用绑定:
Creates an Array
in @a
, iterates something
, and stores each element in @a
. If binding is used instead:
my @list := (2,) but "bar";
put @list.Str;
然后将带有mixin的列表绑定到符号@list
,输出为:
Then the list with the mixin is bound to the symbol @list
, and the output is:
bar
这篇关于当原始变量具有默认强制时,有没有办法访问混合组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文