Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Created July 3, 2019 16:45
Show Gist options
  • Save automationhacks/428f673b96460982d0f20da6dcf2605d to your computer and use it in GitHub Desktop.
Save automationhacks/428f673b96460982d0f20da6dcf2605d to your computer and use it in GitHub Desktop.
Demonstrates how we can lift assignments out of if elses
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