mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
py: Implement default and star args for lambdas.
This commit is contained in:
12
tests/basics/lambda_defargs.py
Normal file
12
tests/basics/lambda_defargs.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# test default args with lambda
|
||||
|
||||
f = lambda x=1: x
|
||||
print(f(), f(2), f(x=3))
|
||||
|
||||
y = 'y'
|
||||
f = lambda x=y: x
|
||||
print(f())
|
||||
|
||||
f = lambda x, y=[]: (x, y)
|
||||
f(0)[1].append(1)
|
||||
print(f(1), f(x=2), f(3, 4), f(4, y=5))
|
||||
Reference in New Issue
Block a user