-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e76e2c7
commit b91e8d5
Showing
5 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Kotlin Night Rochester 2019 | ||
|
||
## Crash Course intro to Kotlin. | ||
|
||
Go through the intro subproject. Start in `io.mfj.kotlinnight.intro.Classes` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,3 +196,5 @@ with comments. This is super nice. | |
*/ | ||
// The comment ended there | ||
|
||
// Let's take a look at collections |
22 changes: 15 additions & 7 deletions
22
intro/src/main/java/io/mfj/kotlinnight/intro/CollectionsIntro.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.mfj.kotlinnight.intro | ||
|
||
// Kotlin lets you add functions to existing classes with Extension Functions | ||
|
||
// This is the syntax to create one: | ||
|
||
fun String.excite():String = "${this}!!!!!!!" | ||
|
||
object Ext { | ||
|
||
@JvmStatic | ||
fun main( args:Array<String> ) { | ||
|
||
// You can call it just like any other function | ||
println( "hello world".excite() ) | ||
} | ||
|
||
} | ||
|
||
// Classes can contain extension functions, and they are in the class' scope | ||
class Foo( private val name:String ) { | ||
|
||
// This extension function has access to the instance. | ||
fun String.said() = "${name} said \"${this}.\"" | ||
|
||
fun sayHello() { | ||
println( "hello world".said() ) | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun main( args:Array<String> ) { | ||
Foo("John").sayHello() | ||
} | ||
} | ||
|
||
} |