On Thu, 20 Mar 2025, Marcos Cruz wrote:
Since Pike does not support default parameter values, I use this
workaround:
```pike
int typed_number(string|void prompt) {
if (!stringp(prompt)) {
prompt = "";
}
// (…)
}
```
Is there a better approach?
In Pike 9.0 (currently in beta) the following syntax is supported:
```pike
int typed_number(string prompt = "") {
// (…)
}
```
It will compile to code similar to
```pike
int typed_number(string|void prompt) {
prompt = prompt || "";
// (…)
}
```
Except that the variable `prompt` will have the type
`string` and not `string|void`.
Did this help?
/grubba
--
Henrik Grubbström gru...@roxen.com
Roxen Internet Software AB