more docs, fixed parsing of an empty string

This commit is contained in:
sergeych committed 2025-06-13 17:59:40 +04:00
1 parent be4f2c7f45
commit cfb2f7f128
3 files changed
+46 -27

No files matched your search

+17 -1
View File
@@ -86,4 +86,20 @@ Lambda functions remember their scopes, so it will work the same as previous:
val c = createLambda()
println(c)
>> 1
>> void
>> void
# Elements of functional programming
With ellipsis and splats you can create partial functions, manipulate
arguments list in almost arbitrary ways. For example:
// Swap first and last arguments in the call
fun swap_args(first, others..., last, f) { f(last, ...others, first) }
assertEquals(
"321",
swap_args( 1, 2, 3 ) { a, b, c -> "" + a + b + c }
)
>>> void
,