Kotlin / kotlin-by-example

The sources of Kotlin by Example.
https://play.kotlinlang.org/byExample/overview
MIT License
460 stars 897 forks source link

Possible typo in datatypes #87

Closed NikolasE closed 5 years ago

NikolasE commented 5 years ago

https://play.kotlinlang.org/byExample/01_introduction/06_Generics


fun <E> mutableStackOf(vararg elements: E) = MutableStack(*elements)

fun main() {
  val stack = mutableStackOf(0.62, 3.14, 2.7)
  println(stack)
}

```Note that the compiler can infer the generic type from the parameters of mutableStackOf so that you don't have to write mutableStackOf<**Int**>(...).

-> shouldn't that be mutableStackOf<**Float**>(...) in this scenario?
p7nov commented 5 years ago

Hi! Thanks, the type is indeed not Int here. Actually, it's Double but, anyway, thanks for noticing. We'll fix this.