improved vairable tracking, fixed plugin to wirk with 1.0.10, fixed lambda comparison
This commit is contained in:
1 parent
1e18a162c4
commit
0732202c80
12 files changed
+266
-28
No files matched your search
@@ -81,8 +81,14 @@ statements discussed later, there could be default values, ellipsis, etc.
|
||||
class Point(x=0,y=0)
|
||||
val p = Point()
|
||||
assert( p.x == 0 && p.y == 0 )
|
||||
|
||||
// Named arguments in constructor calls use colon syntax:
|
||||
val p2 = Point(y: 10, x: 5)
|
||||
assert( p2.x == 5 && p2.y == 10 )
|
||||
>>> void
|
||||
|
||||
Note that unlike **Kotlin**, which uses `=` for named arguments, Lyng uses `:` to avoid ambiguity with assignment expressions.
|
||||
|
||||
## Methods
|
||||
|
||||
Functions defined inside a class body are methods, and unless declared
|
||||
|
||||
@@ -123,7 +123,7 @@ Rules:
|
||||
- A named argument cannot reassign a parameter already set positionally.
|
||||
- If the last parameter has already been assigned by a named argument (or named splat), a trailing block is not allowed and results in an error.
|
||||
|
||||
Why `:` and not `=` at call sites? In Lyng, `=` is an expression (assignment), so we use `:` to avoid ambiguity. Declarations continue to use `:` for types, while call sites use `as` / `as?` for type operations.
|
||||
Why `:` and not `=` at call sites? In Lyng, `=` is an expression (assignment), so we use `:` to avoid ambiguity. This is a key difference from **Kotlin**, which uses `=` for named arguments. Declarations in Lyng continue to use `:` for types, while call sites use `as` / `as?` for type operations.
|
||||
|
||||
## Named splats (map splats)
|
||||
|
||||
|
||||
@@ -439,6 +439,19 @@ It is possible to define also vararg using ellipsis:
|
||||
|
||||
See the [arguments reference](declaring_arguments.md) for more details.
|
||||
|
||||
## Named arguments
|
||||
|
||||
When calling functions, you can use named arguments with the colon syntax `name: value`. This is particularly useful when you have many parameters with default values.
|
||||
|
||||
```lyng
|
||||
fun test(a="foo", b="bar", c="bazz") { [a, b, c] }
|
||||
|
||||
assertEquals(["foo", "b", "bazz"], test(b: "b"))
|
||||
assertEquals(["a", "bar", "c"], test("a", c: "c"))
|
||||
```
|
||||
|
||||
**Note for Kotlin users:** Lyng uses `:` instead of `=` for named arguments at call sites. This is because in Lyng, `=` is an expression that returns the assigned value, and using it in an argument list would create ambiguity.
|
||||
|
||||
## Closures
|
||||
|
||||
Each __block has an isolated context that can be accessed from closures__. For example:
|
||||
|
||||
Reference in new issue
Block a user