Several changes on Kontlin. (#2335)

* kotlin: remove unnecessary semicolons.

Also replace code block language `java` with `kotlin`.

* kotlin: change coding style (Kotlin Reference)

* kotlin: anonymous function -> lambda expression

Anonymous functions and lambda expressions are different in Kotlin.
The code example uses `anonymous function` in the comment,
while the code below is in fact lambda expressions.

* Remove myself from contributors.

Not for trivial changes.

* kotlin: fix a typo.

Thanks @geoffliu to point out this.

* kotlin: change style of default parameter according to Referenec.
This commit is contained in:
Jakukyo Friel 2016-10-12 17:47:41 +08:00 committed by ven
parent c77d5655ec
commit 858171d723

View File

@ -9,7 +9,7 @@ Kotlin is a statically typed programming language for the JVM, Android and the
browser. It is 100% interoperable with Java. browser. It is 100% interoperable with Java.
[Read more here.](https://kotlinlang.org/) [Read more here.](https://kotlinlang.org/)
```java ```kotlin
// Single-line comments start with // // Single-line comments start with //
/* /*
Multi-line comments look like this. Multi-line comments look like this.
@ -42,12 +42,12 @@ fun main(args: Array<String>) {
Strings can be represented in a similar way as in Java. Strings can be represented in a similar way as in Java.
Escaping is done with a backslash. Escaping is done with a backslash.
*/ */
val fooString = "My String Is Here!"; val fooString = "My String Is Here!"
val barString = "Printing on a new line?\nNo Problem!"; val barString = "Printing on a new line?\nNo Problem!"
val bazString = "Do you want to add a tab?\tNo Problem!"; val bazString = "Do you want to add a tab?\tNo Problem!"
println(fooString); println(fooString)
println(barString); println(barString)
println(bazString); println(bazString)
/* /*
A raw string is delimited by a triple quote ("""). A raw string is delimited by a triple quote (""").
@ -125,10 +125,10 @@ fun helloWorld(val name : String) {
// Named functions can be specified as arguments using the :: operator. // Named functions can be specified as arguments using the :: operator.
val notOdd = not(::odd) val notOdd = not(::odd)
val notEven = not(::even) val notEven = not(::even)
// Anonymous functions can be specified as arguments. // Lambda expressions can be specified as arguments.
val notZero = not {n -> n == 0} val notZero = not {n -> n == 0}
/* /*
If an anonymous function has only one parameter If a lambda has only one parameter
then its declaration can be omitted (along with the ->). then its declaration can be omitted (along with the ->).
The name of the single parameter will be "it". The name of the single parameter will be "it".
*/ */