How do I declare a class attribute as a union of class names?

前端 未结 3 1923
别那么骄傲
别那么骄傲 2021-01-12 08:41

I\'m reading a spreadsheet looking for different structures. When I tried the following using Moose it seems to do what I want. I could create different types of objects, as

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 08:46

    You could use where

    has $.found is rw where Sch_Symbol|Chip_Symbol|Net;
    

    or define new type by subset

    subset Stuff where Sch_Symbol|Chip_Symbol|Net;
    
    class Cell {
        has Str   $.str_val is required;
        has Str   $.x_id    is required;
        has Str   $.color;
        has Str   $.border;
        has Stuff $.found   is rw;
    }
    

提交回复
热议问题