Skip to content

Instantly share code, notes, and snippets.

@thomasnield
Created June 2, 2018 05:43
Show Gist options
  • Select an option

  • Save thomasnield/b46240d686606c50f9d1fdf35a822858 to your computer and use it in GitHub Desktop.

Select an option

Save thomasnield/b46240d686606c50f9d1fdf35a822858 to your computer and use it in GitHub Desktop.
Kotlin Puzzler- Elvis Backfires
val x: Int? = 2
val y: Int = 3
val sum = x?:0 + y
println(sum)
@thomasnield

thomasnield commented Jun 2, 2018

Copy link
Copy Markdown
Author

To get the answer you thought you were going to get:

val x: Int? = 2
val y: Int = 3

val sum = (x?:0) + y 
    
println(sum)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment