Skip to content

Commit 2a19729

Browse files
committed
added return types in lambas
Signed-off-by: d4v1d03 <[email protected]>
1 parent 39089b1 commit 2a19729

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/user_docs/support/faq-kcl.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,3 +2512,17 @@ worldString: world
25122512
s: Hello world
25132513
raw_s: Hello ${worldString}
25142514
```
2515+
2516+
## 59. How does KCL infer return types in lambdas?
2517+
2518+
For lambda(s),KCL automatically infers the return value type in the function body, although we can explicitly specify it. An example KCL code over here is:
2519+
2520+
``KCL
2521+
f1 = lambda t: Type1 {
2522+
Type2 {}
2523+
} # The type of f1 is (Type1) -> Type2
2524+
2525+
f2 = lambda t: Type1 -> Type2 {
2526+
Type2 {}
2527+
} # The type of f2 is (Type1) -> Type2
2528+
```

0 commit comments

Comments
 (0)