Rafael Costa
08/13/2025, 9:48 AMfun bar(
lambda: context(String) () -> Unit
) {
with("") {
lambda()
}
}
fun foo() {
bar {
this // error
}
}
Am I missing something? Is this not supposed to give me a string?
I am not able to get the context parameter of the lambda in any way. If I try bar { str ->
then "str" here is also an error 🤔Joffrey
08/13/2025, 9:49 AMRafael Costa
08/13/2025, 9:50 AMJoffrey
08/13/2025, 9:50 AM#general-kotlin-questions
or something along those lines.Rafael Costa
08/13/2025, 9:52 AMhho
08/13/2025, 9:53 AMmbonnin
08/13/2025, 11:53 AMmbonnin
08/13/2025, 11:54 AMAlejandro Serrano.Mena
08/25/2025, 8:01 AMbar
declares the lambda with a context parameter, this is not accessible using this
, but rather using contextOf<String>()