access-company / kotlin_intro

introduction of Kotlin!
9 stars 5 forks source link

すべてのページでKotlin Playgroundが動くか検証する #49

Closed ghost closed 2 years ago

ghost commented 2 years ago

Kotlin Playgroundで各所のコードがちゃんと動くか検証する。mainメソッドがないと動かないのでは?と思っており

45 ができてる前提

magicant commented 2 years ago

やっぱこれ全部 main 関数に入れておかないとダメなのかな。自動で main 関数化してくれると良いのだが……。 (などと、 https://github.com/Kotlin/kotlin-by-example/blob/80517e2ce8da32c8fde205ad7b09a4977a3c97df/examples/01_introduction/03_Variables.md の書かれ方を見て思った)

komitake commented 2 years ago

https://blog.jetbrains.com/kotlin/2018/04/embedding-kotlin-playground/ Often you don’t want to show all the code in the snippet, but instead only the most interesting and substantial parts of it. This is possible as well.

https://github.com/JetBrains/kotlin-playground/blob/master/examples.md The test clases in this code snippet are folded away thanks to the //sampleStart and //sampleEnd comments in the code. If you want to hide test classes completely just set the attribute folded-button to false value.

とかを見ると、 main関数は必要だけど、 //sampleStart //sampleEnd で隠してどうぞってことでしょうね。