title: Retrieving a Variable output from IF or ELSE condition in KOTLIN
body: <p>I am trying to retrieve the output value from else condition in Kotlin.  I am not sure how to store the data outside If or Else condition. Any help is appreciated. </p>
  
  <pre><code>  else
          {
              var data=db.readData()
  
              for (i in 0..data.size - 1)
              {
                  var data=db.readData()
                  var output=data.get(i).name
                  println("Result is $output")
              }
  
          }
  
  //Need to Get Output here
  var test=output??
  </code></pre>