Skip to content
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

Function Declaration: Default Value #4808

Open
staycoolcall911 opened this issue Nov 6, 2023 · 1 comment
Open

Function Declaration: Default Value #4808

staycoolcall911 opened this issue Nov 6, 2023 · 1 comment
Labels
🛠️ compiler Compiler 📜 lang-spec-impl Appears in the language spec roadmap

Comments

@staycoolcall911
Copy link
Contributor

The default value notation (= y) may appear in declarations of struct fields, class fields or function arguments.

The following sections of the language reference should mention the default value notation:

  1. 1.6.1.4 Function arguments (under 1.6 optionality):

Alternatively, using the default value notation can be used to allow a parameter not to be assigned
when calling the function. Using a default value in the function declaration ensures that by
always has a value so there is no need to unwrap it (this is why its type is num and not num?):

let increment = (x: num, by: num = 1): num {
  return x + by;
}
  1. 1.7 Type Inference

Function argument type is inferred iff a default value is provided.

Copy link

github-actions bot commented Jan 6, 2024

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ compiler Compiler 📜 lang-spec-impl Appears in the language spec roadmap
Projects
Status: 🤝 Backlog - handoff to owners
Status: Todo - p1
Development

No branches or pull requests

1 participant