What’s Kotlin REPL?
The REPL lets you practice your Kotlin and you can also use it to quickly to check whether a code snippet will work without compiling the whole project. So in IntelliJ, you can get to it by going to:
Tools -> Kotlin -> and then down to Kotlin REPL here and it opens up at the bottom.
it will execute by clicking Ctrl+Enter not only enter so don’t forget that and just click enter and wait for an output!
We can do mathematical stuff here like 5 + 2 then click Ctrl+Enter, you will get 7 as an output (no need to call print, kotlin knows you just want to output stuff here, but you can if you want.
also, the REPL knows about the definitions in your project so we can reference them. So, for example, we could start typing Student and it will actually suggest the Student definition that we have in our project.
so let’s create an object of Student and print it (remember no need to print, you can just use student1.name and it will print it )
So the REPL knows about definitions in your project, you do have to import them but it’s aware of them and it also knows about previous definitions you’ve made, you want to play with some code, without having to compile and run it.
This is a great way to do it and you know when you’re first learning Kotlin, before you type a long statement into your file, you might want to try the REPL and make sure it’s going to do what the statements going to do, what you expect it to do.
That’s it for the REPL, Let me fix the missing posts I forgot to publish:D, See you later!