_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

Feature Request: Default values for parameters of events and functions

Open ajusa opened this issue 2 years ago • 1 comments

Easier to show rather explain:

on reset(count = #words.children.length)
def nextWord(value = '')

If the event property wasn't set, then allow an expression to be evaluated for the default value of that property. Similarly, if an argument wasn't passed in, allow an expression to be evaluated for the default value of that argument to a function. I'm suggesting the = syntax, but other words may make sense as well (such as default). Note that this may be complicated once multiple arguments are concerned, such as

def nextWord(value = '', value2, value3 = 5)

ajusa avatar Dec 19 '21 15:12 ajusa

The default command can be used here:

on reset(count)
  default count to #words.children.length

Not shutting down the discussion, just pointing it out for anyone who might not be aware.

dz4k avatar Dec 19 '21 16:12 dz4k