This file contains hidden or 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
public interface Iterable<out T> { | |
public abstract operator fun iterator(): Iterator<T> | |
} |
This file contains hidden or 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
public interface MutableIterable<out T> : Iterable<T> { | |
override fun iterator(): MutableIterator<T> | |
} |
This file contains hidden or 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
public interface MutableCollection<E> : Collection<E>, MutableIterable<E> { | |
override fun iterator(): MutableIterator<E> | |
public fun add(element: E): Boolean | |
public fun remove(element: E): Boolean | |
public fun addAll(elements: Collection<E>): Boolean | |
public fun removeAll(elements: Collection<E>): Boolean | |
public fun retainAll(elements: Collection<E>): Boolean | |
public fun clear(): Unit | |
} |
This file contains hidden or 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
var numbers: List<Int> = listOf(1, 2, 3, 4, 5) | |
var names: List<String> = listOf("sajjad", "mammad", "gholam") | |
for (name in names) { | |
println(name) | |
} |
This file contains hidden or 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
sajjad | |
mammad | |
gholam |
This file contains hidden or 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
var listMixedTypes = listOf("sajjad", 1, 2.445, 's') // will still compile |
This file contains hidden or 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
val emptyList: List<String> = emptyList<String>() |
This file contains hidden or 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
val nonNullsList: List<String> = listOfNotNull(2, 45, 2, null, 5, null) |
This file contains hidden or 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
println(names.size) // 3 | |
println(names.get(0)) // "Chike" | |
println(names.indexOf("Mgbemena")) // 2 | |
println(names.contains("Nnamdi")) // 'true' |
This file contains hidden or 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
val stringList: ArrayList<String> = arrayListOf<String>("Hello", "You", "There") |