DEV Community

Cover image for From Theory to Code: My Kotlin Journey. Part 1
ojubizimnitsuj
ojubizimnitsuj

Posted on

From Theory to Code: My Kotlin Journey. Part 1

In my last post, I introduced my journey. Today , I'm following the https://kotlinlang.org/docs/home.html to write my very first lines of code.

The Entry point: fun main()

Every Kotlin program needs a "start" button. The official guide explains that the 'main' function is the mandatory entry point.

Making the code talk: println() vs print()

I experimented with the two output functions the guide introduces. Here's what I did to see how they differ:

  • println(): It prints the text and then moves to a new line.

  • print(): It prints the text but keeps the cursor on the same line.

A Quick Tip: No Notebook Needed!

Instead of grabbing a pen and paper to remember what println() does, I learned that I can take notes directly inside my code. The Kotlin SDK(and the playground) ignores these notes, so they don't break the program.
You can use two types of comments for my notes:

  • Single-line notes: Just add '//' and everything after it on that line is a note.

  • Multi-line notes: Wrap bigger notes between '/' and '/'.
    Beyond being notes, those notes will make your program 'self documenting' and will be a great way to show your progress as a developer!

Here is the result:

Now it is your turn, feel free to share what you've done!

Top comments (0)