You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the following to load a multi-line file into a string array:
const fileOrNull: Descriptor | null = FileSystem.open(filename, "r");
if (fileOrNull == null) {
throw new Error("Could not open the file " + filename);
}
const file = changetype<Descriptor>(fileOrNull);
const lines = new Array<string>();
let line = changetype<string>(file.readLine());
do {
lines.push(line);
line = changetype<string>(file.readLine());
} while(line)
return lines;
However, give the following input:
one
two
three
The result is an array ["one", "two"] - the readLine method appears to return null prematurely
The text was updated successfully, but these errors were encountered:
Btw you could nicer cast to non-nullable type without changetype:
constfile=FileSystem.open(filename,"r")if(file==null){thrownewError("Could not open the file "+filename)}constlines: string[]=[]letline=file!.readLine()do{lines.push(line!)line=file!.readLine()}while(line)returnlines
I'm using the following to load a multi-line file into a string array:
However, give the following input:
The result is an array
["one", "two"]
- thereadLine
method appears to return null prematurelyThe text was updated successfully, but these errors were encountered: