Last active
October 14, 2018 14:15
-
-
Save ciferkey/add920dc3bfc1297f20c9ee9a11182a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Notice the parameter is now of type "Workbook.() -> Unit" rather than "(Workbook) -> Unit" | |
fun workbook(block: Workbook.() -> Unit): Workbook { | |
var wb = HSSFWorkbook() | |
block(wb) | |
return wb | |
} | |
fun tryItOut() { | |
// Since we defined the lambda as using a Receiver Type of "Workbook.()" we can now directly call the methods without referencing the paramter | |
workbook { | |
setHidden(true) | |
setSelectedTab(2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment