A project I'm using to start learning about Kotlin.
In the beginning, I plan on solving simple Kotlin exercises found on Exercism and Kotlin Koans.
I am coming from C#, and aim to populate my Kotlin from C# cheat sheet below as I advance through the exercises.
Kotlinfun functionName(inputName: InputType): ReturnType { ... }
C#ReturnType MethodName(InputType inputName) { ... }
Kotlinfun equalsOne(number: Int): Boolean { return number == 1 }
C#bool EqualsOne(int number) { return number == 1; }
When a function/method does not return anything, ReturnType
is omitted in Kotlin:
Kotlinfun doNothing() { }
C#void DoNothing() { }
Default arguments in Kotlin correspond to optional arguments in C#. They are provided in the exact same way.
Kotlinfun equalsOne(number: Int = 1): Boolean { return number == 1 }
C#bool EqualsOne(int number = 1) { return number == 1; }
Named arguments exist in both Kotlin and C#.
KotlinequalsOne(number = 0)
C#EqualsOne(number: 0)