Skip to content

Commit

Permalink
fix(docs): code sample for cloud.Function that doesn't compile (#6054)
Browse files Browse the repository at this point in the history
Fix multiple errors in code sample of cloud.Function that doesn't compile.

## Checklist

- [X] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [X] Description explains motivation and solution
- [ ] Tests added (always)
- [X] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
ShaiBer authored Mar 25, 2024
1 parent effc7ac commit 9ac19f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ target/

# turbo
.turbo/

.history/
6 changes: 3 additions & 3 deletions docs/docs/04-standard-library/cloud/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ bring cloud;
bring util;

// defining a cloud.Function resource
let countWords = new cloud.Function(inflight (s: str): str => {
return "${s.split(" ").length}";
let countWords = new cloud.Function(inflight (s: str?): str => {
return "{s?.split(" ")?.length ?? 0}";
}) as "countWords";

let longTask = new cloud.Function(inflight () => {
Expand All @@ -47,7 +47,7 @@ new cloud.Function(inflight () => {
let sentence = "I am a sentence with 7 words";
// invoking cloud.Function from inflight context
let wordsCount = countWords.invoke(sentence);
log("'${sentence}' has ${wordsCount} words");
log("'{sentence}' has {wordsCount ?? "0"} words");

longTask.invokeAsync("");
log("task started");
Expand Down
6 changes: 3 additions & 3 deletions libs/wingsdk/src/cloud/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ bring cloud;
bring util;

// defining a cloud.Function resource
let countWords = new cloud.Function(inflight (s: str): str => {
return "${s.split(" ").length}";
let countWords = new cloud.Function(inflight (s: str?): str => {
return "{s?.split(" ")?.length ?? 0}";
}) as "countWords";

let longTask = new cloud.Function(inflight () => {
Expand All @@ -47,7 +47,7 @@ new cloud.Function(inflight () => {
let sentence = "I am a sentence with 7 words";
// invoking cloud.Function from inflight context
let wordsCount = countWords.invoke(sentence);
log("'${sentence}' has ${wordsCount} words");
log("'{sentence}' has {wordsCount ?? "0"} words");

longTask.invokeAsync("");
log("task started");
Expand Down

0 comments on commit 9ac19f2

Please sign in to comment.