SHARE
TWEET

Untitled

a guest Jul 17th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // I've tried:
  2. var fos: FileOutputStream?;
  3. for (...) {
  4.     if (condition met) {
  5.         if (fos == null) { // compiler error: not initialized
  6.             fos = FileOutputStream(filename);
  7.         }
  8.     }
  9.     fos.write(something)
  10. }  
  11. // Also this
  12. var fosCreated: Boolean = false;
  13. var fos: FileOutputStream?;
  14. for (...) {
  15.     if (condition met) {
  16.         if (!fosCreated) { // compiler error: not initialized
  17.         fos = FileOutputStream(filename);
  18.         fosCreated = true;
  19.     }
  20.     fos.write(something)
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top