Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour of is operator on Int and Double #1

Open
flonso opened this issue Oct 11, 2017 · 0 comments
Open

Behaviour of is operator on Int and Double #1

flonso opened this issue Oct 11, 2017 · 0 comments

Comments

@flonso
Copy link
Owner

flonso commented Oct 11, 2017

The following Kotlin code doesn't produce the same output on both Kotlin "stock" compiler and the Kotlin-Scala.js compiler :

fun main(args: Array<String>) {
    val myDouble = 1.7

    check(myDouble)
}

fun check(a: Any) {

    if (a is Int) println("$a is an Int")
    if (a is Double) println("$a is a Double")
    if (a is Long) println("$a is a Long")


    if (a !is Int) println("$a is not an Int")
    if (a !is Double) println("$a is not a Double")
    if (a !is Long) println("$a is not a Long")
}

Output for KotlinJS compiler :

1.7 is an Int
1.7 is a Double
1.7 is not a Long

Output for Kotlin-Scala.js compiler :

1.7 is a Double
1.7 is not an Int
1.7 is not a Long

Need to investigate the reason behind this difference.

flonso added a commit that referenced this issue Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant