how can you create <such> a DSL with `+` and `-` o...
# getting-started
e
how can you create such a DSL with
+
and
-
operators with implicit receiver?
Copy code
branchFilter {
                +"refs/heads/my-feature"
            }
c
The key concepts are: • extension functions • operators can be extension functions • lambdas can be extension functions Now, all you have to do is create a
branchFilter
function that takes a parameter that is lambda with a receiver on some class (eg.
BranchFilterDSL
). Now, all functions declared in
BranchFilterDSL
(or as extensions of
BranchFilterDSL
) are available inside the lambda, and not outside of it.
e
yeah, but as far as I know, you can't use the
+
form unless you have an explicit receiver, ie
receiver + "refs"
ah, it's the
unaryPlus
!
👌 1
t