Skip to content

Instantly share code, notes, and snippets.

@ciferkey
Last active October 14, 2018 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciferkey/add920dc3bfc1297f20c9ee9a11182a5 to your computer and use it in GitHub Desktop.
Save ciferkey/add920dc3bfc1297f20c9ee9a11182a5 to your computer and use it in GitHub Desktop.
// 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