Open staycoolcall911 opened 1 year ago
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!
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!
This issue originally had default value support for struct, function and class. I updated this issue to relate to struct only, while adding #4808 for function and #4807 for class
Hi,
This issue hasn't seen activity in 90 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!
Hi,
This issue hasn't seen activity in 90 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!
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:
The default value notation (
= y
) in declarations of struct fields or function arguments will use this value if a value is not provided, and implies type isT
(notT?
).The default value notation (
=
) can also be used in struct declarations. If provided, the field is also not required in a struct literal definition, and the default value will be implied. It also means that the type of the field must beT
and notT?
, because we can ensure it has a value (in the example below the fieldradix
as a type ofnum
).A value can be omitted from a struct literal if the field is optional or if it has a default value in the struct declaration. If an optional field doesn't have a default value, its type must be
T?
(someOptional
above). If it has a default value it's type must beT
(radix
above). This is a compilation error: