https://kotlinlang.org logo
#github-workflows-kt
Title
# github-workflows-kt
l

louiscad

11/17/2023, 11:03 AM
Looking into the tests… What syntax do you prefer? (both are working fine now)
Copy code
expr { env.GITHUB_ACTIONS } shouldBe "$dollar{{ GITHUB_ACTIONS }}"
expr { env.GITHUB_ACTIONS } shouldBe "\${{ GITHUB_ACTIONS }}"
1️⃣ 1
2️⃣ 2
l

LeoColman

11/17/2023, 11:08 AM
Copy code
abc shouldBe ("$" + "{{ GITHUB_ACTIONS }}")
l

louiscad

11/17/2023, 11:09 AM
Why do you prefer resorting to concatenation when backslash works?
l

LeoColman

11/17/2023, 11:10 AM
This makes it clear that I want a $ before everything, and separating the two parts with a
+
is easier on my eyes to understand what exactly I'm trying to test
In prod code I'll probably go for String template, but for testing - where my goal is to show other humans wtf I'm testing - I prefer to make it a little bit more "explain like I'm 5"
My problem with concatenation is that it's ugly, but sometimes (mainly when using $) it can be clearer
Reminds me of having to do something like "${"$"}" to escape the dollar xD
l

louiscad

11/17/2023, 11:12 AM
Wouldn't explaining the backslash to a 5 years old work just as well, if not better?
Also, it's not like we get 5 year old folks contributing 😄
😂 1
l

LeoColman

11/17/2023, 11:17 AM
They probably all compile down to the exact same thing, right?
I think it's up to personal preference. Do you have a particular reason to dislike concatenation? In this particular case it's not that obscene as
"www" + website + Constants.SLASH + "path" + variable + ...
l

louiscad

11/17/2023, 11:24 AM
It adds many more characters, which is greater noise IMHO
1
l

LeoColman

11/17/2023, 11:36 AM
Maybe it's a problem for me. I have a hard time reading
\${{}}
-- Like having to force my brain to think what it means instead of just 'knowing'
And of course this takes less than 2 seconds, so it's purely a style choice
What about
Copy code
abc should be """${{ GITHUB_ACTIONS }}"""
☝️ 1
It would add a couple more
"
, but remove the """"ambiguity"""" of escaping the
$
l

louiscad

11/17/2023, 1:07 PM
It doesn't work because string templates are allowed in multiline strings as well.
To me
\
means "we're not putting a Kotlin variable or expression in there, it's just a
$
character."
l

LeoColman

11/17/2023, 1:14 PM
But ${ isn't a string template, so it won't try to auto-complete in
"""
, right?
Maybe I'm remembering it wrong
l

louiscad

11/17/2023, 1:24 PM
Try and you'll see. play.kotl.in
👍 1
"""${{ lol }}"""
doesn't compile
Unless
lol
is defined of course
l

LeoColman

11/17/2023, 1:25 PM
Dammit,
${
is actually a template due to
${foo.bar}
I confused it with
$(
, which would probably compile fine
l

louiscad

11/17/2023, 1:25 PM
Yup, it does