f getFileContent(path){
if (!File::isExist(path)) {
file = new File(path);
file.put("This is something default");
file.save();
} else {
file = File::fromPath(path)
}
return file.content;
return file_content(path)
}
# Вариант 2:
f getFileContent(path){
try {
file = File::fromPath(path)
return file.content;
}
catch FileNotFoundException {
file = new File(path);
file.put("This is something default");
file.save();
return file.content
}
}
# Вариант 1:
f getFileContent(filename){
if (!file_exists(filename)) {error: file not found}
return file_content(filename)
}
# Вариант 2:
f getFileContent(filename){
try return file_content(filename)
catch FileNotFoundException {error: file not found}
}
# Вариант 1:
f getFileContent(filename){
if (!file_exists(filename)) {error: file not found}
return file_content(filename)
}
# Вариант 2:
f getFileContent(filename){
try return file_content(filename)
catch FileNotFoundException {error: file not found}
}
Ваш ответ мне понятен, спасибо большое :)