Skip to content

Commit 1143ffd

Browse files
authored
Merge pull request #381 from d4v1d03/main
use of mixin attributes
2 parents 014bb8f + 34a9100 commit 1143ffd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/user_docs/support/faq-kcl.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,3 +2683,32 @@ p:
26832683
fullName: Alice White
26842684
```
26852685

2686+
## 67. Does the use of mixed-in attributes outisde of mixin requires casting to `any` type ?
2687+
2688+
You need to add specifically the type into the schema. An example code shown below:
2689+
2690+
```KCL
2691+
schema FooBar:
2692+
mixin [
2693+
FooBarMixin
2694+
]
2695+
foo: str = 'foo'
2696+
bar: str = 'bar'
2697+
2698+
protocol FooBarProtocol:
2699+
foo: str
2700+
bar: str
2701+
2702+
mixin FooBarMixin for FooBarProtocol:
2703+
foobar: str = "${foo}.${bar}" # Attribute with the annotation can be accessed outside the schema.
2704+
2705+
_c = FooBar {}
2706+
foobar = _c.foobar
2707+
```
2708+
2709+
returns the output:
2710+
2711+
```bash
2712+
foobar: foo.bar
2713+
```
2714+

0 commit comments

Comments
 (0)