Skip to content

Commit ab86574

Browse files
committed
more comments for demo
1 parent f70c21c commit ab86574

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/main/kotlin/me/kotlindemo/01_IntroToKotlin.kt

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import kotlin.IllegalArgumentException
1212
* 1. Destructuring https://kotlinlang.org/docs/reference/multi-declarations.html
1313
*/
1414

15+
/**
16+
* this looks familiar! intellij autocomlentes if you start typing 'main'
17+
*/
1518
fun main() {
1619
someVariableStuff()
1720
functions()
@@ -69,6 +72,13 @@ fun paramsWithDefaultValues(one: String = "blah", two: Boolean = false, three: I
6972
println("\n fun params with default values: one: $one two:$two three: $three, fourNullable: $fourNullable")
7073
}
7174

75+
/**
76+
* Function params are val (immutable). Compile time errors result if you 'var' it
77+
*/
78+
//fun paramsAreDefaultVal(inputString: String. var anotherInputString: String) { //compile error on var, 'expecting type name'
79+
//// inputString = "blah" //val cannot be reassigned compile error
80+
//}
81+
7282
/**
7383
* Lambdas
7484
* Similar to the way java does them for the most part, with a bit less verbage
@@ -162,8 +172,8 @@ fun someFunWithEquals() {
162172
println(" Showing equals")
163173
val personOne = Person("blah", "Johnny", "Walker")
164174
val personTwo = Person("blah", "Johnny", "Walker")
165-
println(" using == in place of .equals structural equality: ${personOne == personTwo}") //== in place of .equals
166-
println(" using === in place of .equals refernentioal equality: ${personOne === personTwo}")
175+
println(" using == is same as .equals testing structural equality: ${personOne == personTwo}") //== in place of .equals
176+
println(" using === tests for referential equality: ${personOne === personTwo}")
167177
}
168178

169179
//implicitly returns Unit

src/main/kotlin/me/kotlindemo/02_Collections.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fun someMapStuff() {
6565
println(" all Keys: ${mapOfNumbers.keys}")
6666
println(" all values: ${mapOfNumbers.values}")
6767
println(" destructuring a map")
68-
for((key, value) in mapOfNumbers) {
68+
for((key, value) in mapOfNumbers) { //destructuring
6969
println(" key: $key value: $value")
7070
}
7171
}

0 commit comments

Comments
 (0)