Hey guys :wave: I'm sorry if I'm not in the right ...
# language-evolution
r
Hey guys 👋 I'm sorry if I'm not in the right channel, I didn't find a better one, but I think it's related enough. I'm trying context parameters, but failing in this case:
Copy code
fun 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 🤔
j
#C0B8MA7FA would be more appropriate for general questions about the language. This channel is about discussing possible language changes.
👍 1
r
Fair enough, although this doesn't feel like a question of someone getting started in kotlin ahah 😅
j
Yeah I agree this is a bit of a misnomer, but organically that's what the channel became. I guess it should probably be
#general-kotlin-questions
or something along those lines.
3
r
In any case, I'll ask the question there 🙂
thank you color 2
h
I think of it as "getting started in this Slack"
m
Context receiver parameters questions definitely don't feel like "getting started"
There is also #CR7H6LTD5
a
just to give a solution, since
bar
declares the lambda with a context parameter, this is not accessible using
this
, but rather using
contextOf<String>()
👍 1