Ben Edwards
08/18/2022, 5:13 PM*val* reader = FileReader("test.txt")
reader.*use* {
reader.read()
}
Which can be replaced by
FileReader("test.txt").use { reader -> read("something") }
Which I am confused by, what is "something" referring to?Joffrey
08/18/2022, 5:19 PMBen Edwards
08/18/2022, 5:22 PMBen Edwards
08/18/2022, 5:22 PMFileReader("test.txt").use { reader -> read() }Matthew Gast
08/18/2022, 5:24 PMreader.read() as use is does not scope Reader but passes it as a parameter (which is what the reader -> is).Joffrey
08/18/2022, 5:25 PMFileReader("test.txt").use { reader -> reader.read() }
FileReader("test.txt").use { it.read() }Ruckus
08/18/2022, 5:41 PMFileReader("test.txt").use(Reader::read)ilya.gorbunov
08/18/2022, 9:49 PMuse passes its receiver as a parameter to the provided lambda, the following two are equivalent:
reader.use { reader.read() }
and
reader.use { it.read() }