Class<haxe.io.Output> has no field writeByte (or any other method in there)

I don’t even understand how it can not find it since I randomly also tried
new HttpBase(“http://www.google.ca”).addHeader(“foo”,“bar”); with no problem.

Can you provide a complete sample? With compilation settings

With a capital O in Output it looks like you are trying to use writeByte as a static function.
You need an actual object of type Output (or one of it’s child classes, like e.g. a FileOutput obtained via File.write(filename)) to use any non static function.

Output has no constructor, so I assumed making it an object wouldn’t help. However, declaring a public static var out:Output; works. I wasn’t aware of that. Thanks a lot @ablum.

Sorry for the noob question :sweat_smile:

Other question, I am aware that writeByte isn’t implemented but how will it, and its brothers, be meant to be used as they return nothing nor modify any variable? Is it because it’s incomplete? I do not quite understand…

I guess what you are after is Sys.stdout().writeByte(...)

1 Like

Output is basically an abstract base class (if you’re familiar with C# vernacular), meaning it is not meant to be instantiated, only derived from.

There are other IO classes that derive from it that have constructors/static factory functions that create instances and have implementations for its methods, like haxe.io.BytesOuput and sys.io.FileOutput (and several other NativeOutput types for different targets)

See the “extended by” section of the API documentation for haxe.io.Output (haxe.io.Output - Haxe development API)

1 Like

I looked around a bit and found out that what I was after was in fact haxe.io.UInt8Array. As I need an array of bytes.