https://kotlinlang.org logo
Title
m

Mykola Gurov

12/20/2021, 9:03 PM
Hi, a noob question. Is there an easy way to reuse a bit of experimental code between the notebooks? So far I see two options: - publish a (local) library. A bit cumbersome for quick adjustment loops. Good for when this code matures enough in the future. - use a lib descriptor json with a bunch of init/initCell. Kinda OKish, but gets messy quick with multiline extension functions using string interpolation :)
And while we’re on this topic, what’s the difference between
init
and
initCell
? They seem to work the same for me.
a

altavir

12/21/2021, 5:58 AM
You can load local jar.
h

holgerbrandl

12/21/2021, 7:39 AM
What about
@file:Import
? Has this landed in the scripting APIs already, and could this be used in a jupyter notebook as well?
a

altavir

12/21/2021, 7:40 AM
It is always problematic to trace dependencies for stand-alone files (they need to be
kts
scripts for that). I just tested and
@file:DependsOn("myJar.jar")
is working perfectly fine.
h

holgerbrandl

12/21/2021, 7:41 AM
Oh, I did not say that it would be good practice. I was just thinking about options.
Thanks for confirming the option! 🙂
a

altavir

12/21/2021, 7:41 AM
Actually, the documentation says that class-directorles should work as well: https://github.com/Kotlin/kotlin-jupyter#dependencies-resolving-annotations
h

holgerbrandl

12/21/2021, 7:41 AM
Nice
a

altavir

12/21/2021, 7:42 AM
But I think it meanse compiled classes