kotlin - Is it possible to hide variables from lambda's closure? -
i'm trying crate type-safe groovy-style builder in kotlin it's described here. problem visibility of lambda receivers in nested lambdas. here simple example.
html { head(id = "head1") body() { head(id = "head2") } }
receiver of nested lambda body doesn't have 'head' method. nevertheless code compiles , prints this:
<html> <head id="head1"></head> <head id="head2"></head> <body></body> </html>
it expected there way compilation error on inner head?
as of kotlin 1.0 not possible. there open feature request functionality.
Comments
Post a Comment