Skip to content

Commit ad22833

Browse files
authored
commit (#763)
1 parent c6e687d commit ad22833

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.baeldung.underscoreoperator
2+
// Before Kotlin 1.7
3+
class Box<T>(value: T) {
4+
// Some class implementation
5+
}
6+
fun main() {
7+
val intBox: Box<Int> = Box(42)
8+
val anyBox: Box<Any> = Box("Some value")
9+
}
10+
fun main1(args: Array<String>) {
11+
val (_, second) = "ignored" to "hello"
12+
println(second)
13+
}
14+
fun mainTwo(args: Array<String>) {
15+
val list = listOf("hi")
16+
val list2 = list.mapIndexed { _, item -> item }
17+
println(list2)
18+
}
19+
inline fun <T> printElementInfo(element: T) {
20+
println("Element: $element")
21+
}
22+
fun mainForHOF() {
23+
printElementInfo<_>(42)
24+
printElementInfo<_>("Hello")
25+
}

0 commit comments

Comments
 (0)