christophsturm
08/06/2022, 7:37 PMfun <Result> doit(lambda: () -> Result={Unit}) {
}
when the lambda is not passed i want Result to be of type Unit. I get the error Required: Result, found: Unit.{}
ephemient
08/06/2022, 8:26 PMdoit<NotUnit>()
call to work?christophsturm
08/06/2022, 8:51 PMsuspend fun <ContextDependency> context(
name: String,
given: (suspend () -> ContextDependency),
contextLambda: suspend ContextDSL<ContextDependency>.() -> Unit
)
this is how it originally looksephemient
08/06/2022, 8:52 PMchristophsturm
08/06/2022, 8:52 PMephemient
08/06/2022, 8:53 PMcontext("name") { /* inferred context of ContextDSL<something other than Unit> */ }
christophsturm
08/06/2022, 8:57 PMoverride suspend fun context(name: String, function: ContextLambda) {
context(name, {}, function)
}
ephemient
08/06/2022, 9:04 PMfun <T> foo()
, the caller can choose any T
(up to constraints you declare on it). you can't constrain it differently based on whether a parameter is present or defaultedchristophsturm
08/06/2022, 9:06 PMephemient
08/06/2022, 9:06 PMchristophsturm
08/06/2022, 9:07 PMephemient
08/06/2022, 9:08 PMGiorgos Makris
08/06/2022, 9:11 PMephemient
08/06/2022, 9:13 PMchristophsturm
08/07/2022, 11:04 AMephemient
08/07/2022, 1:50 PMchristophsturm
08/07/2022, 1:57 PMephemient
08/07/2022, 2:35 PMchristophsturm
08/08/2022, 8:30 AMephemient
08/09/2022, 12:55 AM