I am trying to learn Pony, and for obvious reasons, one of the first things I want to do is print values.
However, it does not seem to work for most things, like:
env.out.print(2 + 2)
Gives the error:
Could not infer literal type, no valid types found
I also tried:
let four: U32 = 2 + 2
env.out.print(four)
But this gives an uglier error saying I need something that is a subtype of ByteSeq
. Fine, but how do I get one of those?
You'll have to convert the integer into a String
.
In Pony there is an interface called Stringable
which declares the function string(fmt)
, and a lots of classes implements that interface. Integers do for instance.
So just call .string()
to convert a value in something printable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With