I am learning android development using kotlin. Being primarily a web developer, I am new to both technology.
While looking for API-29 Connectivity Solution (NetworkInfo
and getActiveNetworkInfo
are deprecated in API-29
), I ran across this expression for variable declaration.
protected var callbackFunction: ((Boolean) -> Unit) = {}
abstract fun startListening(callback: (Boolean) -> Unit)
How would I interpret this? Do I say, variable callbackFunction is of type Boolean, Or of type Unit
. Or something else. In that abstract function, is callback type of Boolean or Unit or something else?
Also I am a bit confused, about the curly braces. Does it mean variable is initialized by an empty anonyms function ( something like in javascript ) or is it something entirely different concept?