Custom Functions
Functions are defined with def
. All user-declared functions must return a value and only use keyword arguments (foo='bar'
).
def foo(s=''):
return s + ' world!'
return foo(s='Hello') # 'Hello world!'
Tip
All argument definitions must be given a default value.
def foo(s): # ERROR
return s + ' world!'
return foo(s='Hello') # 'Hello world!'
Tip
Unlike with Python, positional arguments are not supported with custom functions. All arguments to a function must always be called with name=value
.
def foo(s=''):
return s + ' world!'
return foo('Hello') # ERROR