Unintended behaviour with toPrintString on char type?
Posted: Fri Jun 19, 2015 1:31 am
It seems that incorrect strings are generated when toPrintString is called on a char inside an enumerable.
Reproducible here:
Expected output:
Actual output:
I've been able to fix it by overriding the charToString method of CobraCore.PrintStringMaker with this:
Reproducible here:
class Demo
def main
print [c'\n']
Expected output:
- Code: Select all
[c'\n']
Actual output:
- Code: Select all
[
]
I've been able to fix it by overriding the charToString method of CobraCore.PrintStringMaker with this:
def charToString(c as char) as String is override
if .level == 0
return c.toString
else
return .charToCobraLiteral(c)