09_defer directory created

This commit is contained in:
Vinicius Silva 2023-12-28 23:57:05 -03:00
parent f696aa4174
commit fceb261963
2 changed files with 18 additions and 0 deletions

2
09_defer/log.txt Normal file
View File

@ -0,0 +1,2 @@
asiofjasodifjasdfasdfasdfasd
asdfasdfasdfasdfasdfasdfsadf

16
09_defer/main.v Normal file
View File

@ -0,0 +1,16 @@
import os
pub fn main(){
ok := false
mut f := os.open('log.txt') or { panic('File cannot be read!') }
defer{
f.close()
}
if !ok{
return
}
}