Added names to return values

This commit is contained in:
zhibog
2019-11-08 20:21:18 +01:00
parent 80cdf8b6a8
commit 672cfd51c3
+5 -5
View File
@@ -71,11 +71,11 @@ write_raw :: proc(path: string, data: []byte) -> bool {
return true;
}
read :: proc(path: string, delimiter := DELIMITER, skip_header := false) -> ([]string, int, bool) {
read :: proc(path: string, delimiter := DELIMITER, skip_header := false) -> (content: []string, row_count: int, is_ok: bool) {
if bytes, isOk := os.read_entire_file(path); isOk {
cols: [dynamic]string;
defer delete(cols);
out: [dynamic]string;
content: [dynamic]string;
row_count := 0;
prev_index := 0;
for i := 0; i < len(bytes); i += 1 {
@@ -98,9 +98,9 @@ read :: proc(path: string, delimiter := DELIMITER, skip_header := false) -> ([]s
}
}
}
for col in cols do append(&out, ..strings.split(col, delimiter));
if skip_header do return out[row_count:], row_count - 1, true;
else do return out[:], row_count, true;
for col in cols do append(&content, ..strings.split(col, delimiter));
if skip_header do return content[row_count:], row_count - 1, true;
else do return content[:], row_count, true;
}
return nil, -1, false;
}