Skip to content

astride/well-hello-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

well-hello-kotlin

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.

Kotlin from C# – Cheat sheet

Function/Method

Signature structure

Kotlin
fun functionName(inputName: InputType): ReturnType {
  ...
}
C#
ReturnType MethodName(InputType inputName)
{
  ...
}

Example

Kotlin
fun 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:

Kotlin
fun doNothing() { }
C#
void DoNothing() { }

Default arguments / Optional arguments

Default arguments in Kotlin correspond to optional arguments in C#. They are provided in the exact same way.

Kotlin
fun equalsOne(number: Int = 1): Boolean {
  return number == 1
}
C#
bool EqualsOne(int number = 1)
{
  return number == 1;
}

Named arguments

Named arguments exist in both Kotlin and C#.

Kotlin
equalsOne(number = 0)
C#
EqualsOne(number: 0)

About

A project I'm using to start learning about Kotlin

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages