etcniom.blogg.se

Kotlin koans
Kotlin koans












Of course, I wanted to do the exercise myself so that I can get the hang of writing Kotlin code. I thought this was incredibly slick because it gave me the change to see the differences between Java and Kotlin. You can see in the video that IntelliJ just did the work of taking the Java code that I copied and pasted into my Kotlin class. When you copy and paste Java code into the IDE, it will offer to translate it to Kotlin for you. It was IntelliJ’s support of Kotlin that blew me away. It wasn’t that I was super impressed with the language itself. When I moved onto part two of the tutorial, I was really impressed. Nevertheless, I decided to continue with the Kotlin tutorial found at. You may need an extra class.After doing the first tutorial on Kotlin, I was impressed, but let’s face it, anyone can do a simple “hello world” style program. Then, try to support adding several time intervals to a date. Use an utility function MyDate.addTimeIntervals() declared in DateUtil.kt You could be able to write the code like this: date + YEAR * 2 + WEEK * 3 + DAY * 15.Īt first, add an extension function 'plus()' to MyDate, taking a TimeInterval as an argument. Support adding years, weeks and days to a date. Your job during the koans will be to replace this function invocation with a meaningful code according to the problem.Ĭlass DateRange( val start : MyDate, val end : MyDate):Iterable val list =arrayListOf()

kotlin koans

In the tasks the function TODO() is used that throws an exception.

kotlin koans

Take a look at function syntax and make the function start return the string "OK".

kotlin koans

Solution proposal for Kotlin koans Introduction














Kotlin koans