When I run a scratch file where would I see the ou...
# intellij
s
When I run a scratch file where would I see the output?

https://i.imgur.com/OjL3tVG.png

g
Bottom left corner, bottom panel “Scratch Output”
But I completely agree, it’s very suboptimal UI, especially with errors, I would prefer to see everything in the same scratch window
s
Scratch output is always empty. I am not seeing anything there. It gets closed as soon as I hit the run command.
g
ahh
I got it
because your scratch doing nothing
it;’s kts file, it doesn’t run main function
just write code on top level
or call main() function manually
s
Thanks. That worked. Do you know why the scratch output is empty? And
println()
doesn't seem to printing in the new line in the Scratch but the Playground does.

https://i.imgur.com/buCB4JW.png

https://pl.kotl.in/UrUzdgWLz
g
It’s strange workflow of scrathc
if output is small, it inlined, if big it will be in output tab
s
I wanted to quickly practice some algo questions but it's too much hassle to do that in a full IDE. Thanks for your help.
g
I would just recommend do not use println
and do not use functions which do println
instead just write expressions one by one, you will see results
👍🏽 1
r
I like the kotlin REPL that's baked with the IDE
s
I had no idea that the Kotlin SDK is available via Snap packages. Damn that makes things so much easier. I can run REPL in my console.
How do I write code in multiple line?
g
I like scratch files mush more than repl
it lacks any ide support
the same as repl, but much more convinient
it also has repl mode, when only the last expression is executing when you rerun it (if you executing some heavy tasks)
s
I want to practice algorithms which means I don't want auto-completion. It seems auto-completion is an IDE level setting and I will have to disable for all projects. I just want shortcuts and formatting. I used d.android.com's Kotlin's Playground. https://developer.android.com/training/kotlinplayground?authuser=1
g
which you don’t have in repl
what is problem to set auto-completion level when you need it?
s
I am not sure what a
auto-completion level
is. Looking into docs I can see that the easiest option for me is to enable power saving mode which gives me shortcuts and reformat but takes away code completion.
Create one project for solving all problems, use worksheets and enable power saving. Worksheet will remain the project and save me from writing main method or compiling, etc. Power saving will disable the code completion. This seems like the best setup to me.
r
Do running. Coroutines work well with scratch files?
s
A quick test tells me it seems to work fine.
g
Yes, it works completely fine, but you have to wrap to runBlocking
r
Great thanks