Created
July 3, 2019 16:45
-
-
Save automationhacks/428f673b96460982d0f20da6dcf2605d to your computer and use it in GitHub Desktop.
Demonstrates how we can lift assignments out of if elses
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
package _05_expressions | |
// Simple HTTP response class | |
class Response(val statusCode : Int) | |
fun main() { | |
// A sample response | |
val response = Response(200) | |
// Conditional statement which decides and gives a value out for further consumption | |
val result : String | |
if (response.statusCode == 200) { | |
result = "Success" | |
} | |
else { | |
result = "Failure" | |
} | |
println("API call results is : $result") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment