Skip to content

Commit 15f7e43

Browse files
authored
[IMPORT] Added support for Kotlin (82 files)
Added support for Kotlin, the imported directory contains 82 files, in Kotlin, Shell, SVG, and PDF formats.
1 parent ca6293d commit 15f7e43

File tree

82 files changed

+706
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+706
-0
lines changed
+34
Loading

Kotlin/Samples/-Script_Kotlin.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ kotlinc -script list_folders.kts "path_to_folder_to_inspect"

Kotlin/Samples/-Script_Kotlin_V1.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ kotlinc -script list_folders.kts "path_to_folder_to_inspect"

Kotlin/Samples/ClassMember.kts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public (default): Visible everywhere
2+
internal: Visible in a module
3+
protected: Visible in subclasses
4+
private: Visible in a class
5+

Kotlin/Samples/ClassMember_V1.kts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public (default): Visible everywhere
2+
internal: Visible in a module
3+
protected: Visible in subclasses
4+
private: Visible in a class
5+

Kotlin/Samples/ClassWords.kts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public, internal, protected, and private.

Kotlin/Samples/ClassWords_V1.kts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public, internal, protected, and private.

Kotlin/Samples/ClassesAreFinal.kt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// open on the class means this class will allow derived classes
2+
open class MegaButton {
3+
4+
// no-open on a function means that
5+
// polymorphic behavior disabled if function overridden in derived class
6+
fun disable() { ... }
7+
8+
// open on a function means that
9+
// polymorphic behavior allowed if function is overridden in derived class
10+
open fun animate() { ... }
11+
}
12+
13+
class GigaButton: MegaButton {
14+
15+
// Explicit use of override keyword required to override a function in derived class
16+
override fun animate() { println("Giga Click!") }
17+
}

Kotlin/Samples/ClassesAreFinal.ktm

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
1// open on the class means this class will allow derived classes
2+
2open class MegaButton {
3+
3
4+
4 // no-open on a function means that
5+
5 // polymorphic behavior disabled if function overridden in derived class
6+
6 fun disable() { ... }
7+
7
8+
8 // open on a function means that
9+
9 // polymorphic behavior allowed if function is overridden in derived class
10+
10 open fun animate() { ... }
11+
11}
12+
12
13+
13class GigaButton: MegaButton {
14+
14
15+
15 // Explicit use of override keyword required to override a function in derived class
16+
16 override fun animate() { println("Giga Click!") }
17+
17}

Kotlin/Samples/ClassesAreFinal_V1.kt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// open on the class means this class will allow derived classes
2+
open class MegaButton {
3+
4+
// no-open on a function means that
5+
// polymorphic behavior disabled if function overridden in derived class
6+
fun disable() { ... }
7+
8+
// open on a function means that
9+
// polymorphic behavior allowed if function is overridden in derived class
10+
open fun animate() { ... }
11+
}
12+
13+
class GigaButton: MegaButton {
14+
15+
// Explicit use of override keyword required to override a function in derived class
16+
override fun animate() { println("Giga Click!") }
17+
}

Kotlin/Samples/ClassesAreFinal_V1.ktm

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
1// open on the class means this class will allow derived classes
2+
2open class MegaButton {
3+
3
4+
4 // no-open on a function means that
5+
5 // polymorphic behavior disabled if function overridden in derived class
6+
6 fun disable() { ... }
7+
7
8+
8 // open on a function means that
9+
9 // polymorphic behavior allowed if function is overridden in derived class
10+
10 open fun animate() { ... }
11+
11}
12+
12
13+
13class GigaButton: MegaButton {
14+
14
15+
15 // Explicit use of override keyword required to override a function in derived class
16+
16 override fun animate() { println("Giga Click!") }
17+
17}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fun main(args: Array<String>) {
2+
greet {
3+
to.place
4+
}.print()
5+
}
6+
7+
// Inline higher-order functions
8+
inline fun greet(s: () -> String) : String = greeting andAnother s()
9+
10+
// Infix functions, extensions, type inference, nullable types,
11+
// lambda expressions, labeled this, Elvis operator (?:)
12+
infix fun String.andAnother(other : Any?) = buildString()
13+
{
14+
append(this@andAnother); append(" "); append(other ?: "")
15+
}
16+
17+
// Immutable types, delegated properties, lazy initialization, string templates
18+
val greeting by lazy { val doubleEl: String = "ll"; "he${doubleEl}o" }
19+
20+
// Sealed classes, companion objects
21+
sealed class to { companion object { val place = "world"} }
22+
23+
// Extensions, Unit
24+
fun String.print() = println(this)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
1fun main(args: Array<String>) {
2+
2 greet {
3+
3 to.place
4+
4 }.print()
5+
5}
6+
6
7+
7// Inline higher-order functions
8+
8inline fun greet(s: () -> String) : String = greeting andAnother s()
9+
9
10+
10// Infix functions, extensions, type inference, nullable types,
11+
11// lambda expressions, labeled this, Elvis operator (?:)
12+
12infix fun String.andAnother(other : Any?) = buildString()
13+
13{
14+
14 append(this@andAnother); append(" "); append(other ?: "")
15+
15}
16+
16
17+
17// Immutable types, delegated properties, lazy initialization, string templates
18+
18val greeting by lazy { val doubleEl: String = "ll"; "he${doubleEl}o" }
19+
19
20+
20// Sealed classes, companion objects
21+
21sealed class to { companion object { val place = "world"} }
22+
22
23+
23// Extensions, Unit
24+
24fun String.print() = println(this)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fun main(args: Array<String>) {
2+
greet {
3+
to.place
4+
}.print()
5+
}
6+
7+
// Inline higher-order functions
8+
inline fun greet(s: () -> String) : String = greeting andAnother s()
9+
10+
// Infix functions, extensions, type inference, nullable types,
11+
// lambda expressions, labeled this, Elvis operator (?:)
12+
infix fun String.andAnother(other : Any?) = buildString()
13+
{
14+
append(this@andAnother); append(" "); append(other ?: "")
15+
}
16+
17+
// Immutable types, delegated properties, lazy initialization, string templates
18+
val greeting by lazy { val doubleEl: String = "ll"; "he${doubleEl}o" }
19+
20+
// Sealed classes, companion objects
21+
sealed class to { companion object { val place = "world"} }
22+
23+
// Extensions, Unit
24+
fun String.print() = println(this)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
1fun main(args: Array<String>) {
2+
2 greet {
3+
3 to.place
4+
4 }.print()
5+
5}
6+
6
7+
7// Inline higher-order functions
8+
8inline fun greet(s: () -> String) : String = greeting andAnother s()
9+
9
10+
10// Infix functions, extensions, type inference, nullable types,
11+
11// lambda expressions, labeled this, Elvis operator (?:)
12+
12infix fun String.andAnother(other : Any?) = buildString()
13+
13{
14+
14 append(this@andAnother); append(" "); append(other ?: "")
15+
15}
16+
16
17+
17// Immutable types, delegated properties, lazy initialization, string templates
18+
18val greeting by lazy { val doubleEl: String = "ll"; "he${doubleEl}o" }
19+
19
20+
20// Sealed classes, companion objects
21+
21sealed class to { companion object { val place = "world"} }
22+
22
23+
23// Extensions, Unit
24+
24fun String.print() = println(this)

Kotlin/Samples/DataClass.kt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fun main(args: Array) {
2+
// create a data class object like any other class object
3+
var book1 = Book("Kotlin Programming", 250)
4+
println(book1)
5+
// output: Book(name=Kotlin Programming, price=250)
6+
}
7+
8+
// data class with parameters and their optional default values
9+
data class Book(val name: String = "", val price: Int = 0)

Kotlin/Samples/DataClass.ktm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1fun main(args: Array) {
2+
2 // create a data class object like any other class object
3+
3 var book1 = Book("Kotlin Programming", 250)
4+
4 println(book1)
5+
5 // output: Book(name=Kotlin Programming, price=250)
6+
6}
7+
7
8+
8// data class with parameters and their optional default values
9+
9data class Book(val name: String = "", val price: Int = 0)

Kotlin/Samples/DataClass_V1.kt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fun main(args: Array) {
2+
// create a data class object like any other class object
3+
var book1 = Book("Kotlin Programming", 250)
4+
println(book1)
5+
// output: Book(name=Kotlin Programming, price=250)
6+
}
7+
8+
// data class with parameters and their optional default values
9+
data class Book(val name: String = "", val price: Int = 0)

Kotlin/Samples/DataClass_V1.ktm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1fun main(args: Array) {
2+
2 // create a data class object like any other class object
3+
3 var book1 = Book("Kotlin Programming", 250)
4+
4 println(book1)
5+
5 // output: Book(name=Kotlin Programming, price=250)
6+
6}
7+
7
8+
8// data class with parameters and their optional default values
9+
9data class Book(val name: String = "", val price: Int = 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for ((key, value) in map) {
2+
println("$key: $value")
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1for ((key, value) in map) {
2+
2 println("$key: $value")
3+
3}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for ((key, value) in map) {
2+
println("$key: $value")
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1for ((key, value) in map) {
2+
2 println("$key: $value")
3+
3}

Kotlin/Samples/ExtensionFunctions.kt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package MyStringExtensions
2+
3+
fun String.lastChar(): Char = get(length - 1)
4+
5+
// >>>
6+
println("Kotlin".lastChar())

Kotlin/Samples/ExtensionFunctions.ktm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1package MyStringExtensions
2+
2
3+
3fun String.lastChar(): Char = get(length - 1)
4+
4
5+
5>>> println("Kotlin".lastChar())
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package MyStringExtensions
2+
3+
fun String.lastChar(): Char = get(length - 1)
4+
5+
// >>>
6+
println("Kotlin".lastChar())
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1package MyStringExtensions
2+
2
3+
3fun String.lastChar(): Char = get(length - 1)
4+
4
5+
5>>> println("Kotlin".lastChar())

Kotlin/Samples/HelloWorld_InKotlin.kt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Hello, World! example
2+
fun main() {
3+
val scope = "World"
4+
println("Hello, $scope!")
5+
}
6+
7+
fun main(args: Array<String>) {
8+
for (arg in args) {
9+
println(arg)
10+
}
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1// Hello, World! example
2+
2fun main() {
3+
3 val scope = "World"
4+
4 println("Hello, $scope!")
5+
5}
6+
6
7+
7fun main(args: Array<String>) {
8+
8 for (arg in args) {
9+
9 println(arg)
10+
10 }
11+
11}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Hello, World! example
2+
fun main() {
3+
val scope = "World"
4+
println("Hello, $scope!")
5+
}
6+
7+
fun main(args: Array<String>) {
8+
for (arg in args) {
9+
println(arg)
10+
}
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1// Hello, World! example
2+
2fun main() {
3+
3 val scope = "World"
4+
4 println("Hello, $scope!")
5+
5}
6+
6
7+
7fun main(args: Array<String>) {
8+
8 for (arg in args) {
9+
9 println(arg)
10+
10 }
11+
11}

Kotlin/Samples/InteractiveShell.kts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$ kotlinc-jvm
2+
type :help for help; :quit for quit
3+
>>> 2 + 2
4+
4
5+
>>> println("Hello, World!")
6+
Hello, World!
7+
>>>
8+
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$ kotlinc-jvm
2+
type :help for help; :quit for quit
3+
>>> 2 + 2
4+
4
5+
>>> println("Hello, World!")
6+
Hello, World!
7+
>>>
8+

Kotlin/Samples/LambdaBrace.kt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// the following statement defines a lambda that takes a single parameter and passes it to the println function
2+
val l = { c : Any? -> println(c) }
3+
// lambdas with no parameters may simply be defined using { }
4+
val l2 = { print("no parameters") }
5+

Kotlin/Samples/LambdaBrace.ktm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1// the following statement defines a lambda that takes a single parameter and passes it to the println function
2+
2val l = { c : Any? -> println(c) }
3+
3// lambdas with no parameters may simply be defined using { }
4+
4val l2 = { print("no parameters") }
5+

Kotlin/Samples/LambdaBrace_V1.kt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// the following statement defines a lambda that takes a single parameter and passes it to the println function
2+
val l = { c : Any? -> println(c) }
3+
// lambdas with no parameters may simply be defined using { }
4+
val l2 = { print("no parameters") }
5+

Kotlin/Samples/LambdaBrace_V1.ktm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1// the following statement defines a lambda that takes a single parameter and passes it to the println function
2+
2val l = { c : Any? -> println(c) }
3+
3// lambdas with no parameters may simply be defined using { }
4+
4val l2 = { print("no parameters") }
5+

0 commit comments

Comments
 (0)