相关疑难解决方法(0)

内容检查部分而非全部类属性

我有一个带有属性的类。我想检查是否定义了一些但不是全部。所以:

class A { 
    has $.a is rw;
    has $.b is rw;
    has $.c is rw;
    has $.d is rw;

    method delete { ... }
}

my A $x .= new(:a<hi>, :d<good>);

## later
$x.b = 'there';

## code in which $x.c may or may not be defined.

## now I want to check if the attributes a, b, and c are defined, without
## needing to know about d
my Bool $taint = False;
for <a b c> { …
Run Code Online (Sandbox Code Playgroud)

class introspection raku

8
推荐指数
1
解决办法
85
查看次数

标签 统计

class ×1

introspection ×1

raku ×1