Skip to content

added return types in lambas #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2512,3 +2512,17 @@ worldString: world
s: Hello world
raw_s: Hello ${worldString}
```

## 59. How does KCL infer return types in lambdas?

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:

``KCL
f1 = lambda t: Type1 {
Type2 {}
} # The type of f1 is (Type1) -> Type2

f2 = lambda t: Type1 -> Type2 {
Type2 {}
} # The type of f2 is (Type1) -> Type2
```