├── .idea ├── .gitignore ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── kotlinc.xml ├── libraries │ └── KotlinJavaRuntime.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── KotlinScopeFunctions.iml ├── libs ├── annotations-13.0-javadoc.jar ├── annotations-13.0-sources.jar ├── annotations-13.0.jar ├── hamcrest-core-1.3-javadoc.jar ├── hamcrest-core-1.3-sources.jar ├── hamcrest-core-1.3.jar ├── junit-4.12-javadoc.jar ├── junit-4.12-sources.jar ├── junit-4.12.jar ├── kotlin-stdlib-1.5.30-javadoc.jar ├── kotlin-stdlib-1.5.30-sources.jar ├── kotlin-stdlib-1.5.30.jar ├── kotlin-stdlib-common-1.5.30-javadoc.jar ├── kotlin-stdlib-common-1.5.30-sources.jar ├── kotlin-stdlib-common-1.5.30.jar ├── kotlin-test-1.5.30-javadoc.jar ├── kotlin-test-1.5.30-sources.jar ├── kotlin-test-1.5.30.jar ├── kotlin-test-junit-1.5.30-javadoc.jar ├── kotlin-test-junit-1.5.30-sources.jar └── kotlin-test-junit-1.5.30.jar ├── out └── production │ └── KotlinScopeFunctions │ ├── META-INF │ └── KotlinScopeFunctions.kotlin_module │ ├── MainKt.class │ └── Person.class └── src └── main └── kotlin └── Main.kt /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/libraries/KotlinJavaRuntime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KotlinScopeFunctions.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /libs/annotations-13.0-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/annotations-13.0-javadoc.jar -------------------------------------------------------------------------------- /libs/annotations-13.0-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/annotations-13.0-sources.jar -------------------------------------------------------------------------------- /libs/annotations-13.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/annotations-13.0.jar -------------------------------------------------------------------------------- /libs/hamcrest-core-1.3-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/hamcrest-core-1.3-javadoc.jar -------------------------------------------------------------------------------- /libs/hamcrest-core-1.3-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/hamcrest-core-1.3-sources.jar -------------------------------------------------------------------------------- /libs/hamcrest-core-1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/hamcrest-core-1.3.jar -------------------------------------------------------------------------------- /libs/junit-4.12-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/junit-4.12-javadoc.jar -------------------------------------------------------------------------------- /libs/junit-4.12-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/junit-4.12-sources.jar -------------------------------------------------------------------------------- /libs/junit-4.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/junit-4.12.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-1.5.30-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-1.5.30-javadoc.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-1.5.30-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-1.5.30-sources.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-1.5.30.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-1.5.30.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-common-1.5.30-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-common-1.5.30-javadoc.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-common-1.5.30-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-common-1.5.30-sources.jar -------------------------------------------------------------------------------- /libs/kotlin-stdlib-common-1.5.30.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-stdlib-common-1.5.30.jar -------------------------------------------------------------------------------- /libs/kotlin-test-1.5.30-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-1.5.30-javadoc.jar -------------------------------------------------------------------------------- /libs/kotlin-test-1.5.30-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-1.5.30-sources.jar -------------------------------------------------------------------------------- /libs/kotlin-test-1.5.30.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-1.5.30.jar -------------------------------------------------------------------------------- /libs/kotlin-test-junit-1.5.30-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-junit-1.5.30-javadoc.jar -------------------------------------------------------------------------------- /libs/kotlin-test-junit-1.5.30-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-junit-1.5.30-sources.jar -------------------------------------------------------------------------------- /libs/kotlin-test-junit-1.5.30.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/libs/kotlin-test-junit-1.5.30.jar -------------------------------------------------------------------------------- /out/production/KotlinScopeFunctions/META-INF/KotlinScopeFunctions.kotlin_module: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | MainKt"* -------------------------------------------------------------------------------- /out/production/KotlinScopeFunctions/MainKt.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/out/production/KotlinScopeFunctions/MainKt.class -------------------------------------------------------------------------------- /out/production/KotlinScopeFunctions/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aticiadem/KotlinScopeFunctions/74c2313eb19f0a743c2ccc7c9a8c29a0a30d954d/out/production/KotlinScopeFunctions/Person.class -------------------------------------------------------------------------------- /src/main/kotlin/Main.kt: -------------------------------------------------------------------------------- 1 | fun main(args: Array) { 2 | //letScopeFunction() 3 | //withScopeFunction() 4 | //runScopeFunction() 5 | //applyScopeFunction() 6 | alsoScopeFunction() 7 | } 8 | 9 | private fun letScopeFunction() { 10 | var str: String? = null 11 | str?.let { 12 | println("Hello") 13 | } 14 | str = "Adem" 15 | str?.let { 16 | println("Hello $it") 17 | } 18 | } 19 | 20 | private fun withScopeFunction() { 21 | val numbers = arrayListOf(1, 2, 3) 22 | with(numbers) { 23 | println("We have $size numbers") 24 | println("Last number is ${last()}") 25 | } 26 | } 27 | 28 | private fun runScopeFunction() { 29 | // compute result as block result 30 | val result = run { 31 | val x = 10 32 | val y = x + 3 33 | y - 10 34 | } 35 | println("Result: $result") 36 | // compute result with receiver 37 | val result2 = "text".run { 38 | val tail = substring(1) 39 | tail.uppercase() 40 | } 41 | println("Result2: $result2") 42 | } 43 | 44 | data class Person(var name: String, var age: Int = 0, var city: String = "") 45 | 46 | private fun applyScopeFunction() { 47 | val adem = Person("Adem").apply { 48 | age = 21 49 | city = "Kocaeli" 50 | } 51 | println(adem) 52 | } 53 | 54 | private fun alsoScopeFunction() { 55 | val strList = arrayListOf(1,2,3,4,5) 56 | strList.also { 57 | it.add(6) 58 | it.add(0,10) 59 | println("str length is ${it.size}") 60 | } 61 | println(strList) 62 | } --------------------------------------------------------------------------------