Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement