duck_tape
duck_tape
MModular
Created by duck_tape on 2/14/2024 in #questions
Creating a string from a DynamicVector Drops the last character in the vector
This example sums up the question:
fn test_stringify() raises:
var example = DynamicVector[Int8]()
example.append(ord("e"))
example.append(ord("x"))

var container = DynamicVector[Int8]()
for i in range(len(example)):
container.append(example[i])
let stringifed = String(container)
assert_equal("ex", stringifed)
# Unhandled exception caught during execution: AssertionError: ex is not equal to e
fn test_stringify() raises:
var example = DynamicVector[Int8]()
example.append(ord("e"))
example.append(ord("x"))

var container = DynamicVector[Int8]()
for i in range(len(example)):
container.append(example[i])
let stringifed = String(container)
assert_equal("ex", stringifed)
# Unhandled exception caught during execution: AssertionError: ex is not equal to e
Is it assuming it's a null terminated string or something?
2 replies