ModularM
Modular3y ago
13 replies
❤🔥

Error with method append with string

When im try use List for string a get error

fn main() raises:
    let list = List[String]()
    list.append("123")


Error:
/home/asifar/http/main.🔥:38:16: error: no matching function in call to 'append': 
    list.append("123")
    ~~~~~~~~~~~^~~~~~~
list.mojo:133:5: note: candidate not viable: method argument #0 cannot bind generic !mlirtype to memory-only type 'String'
    fn append(inout self, value: T):
    ^
list.mojo:139:5: note: candidate not viable: method argument #0 cannot be converted from 'StringLiteral' to 'List[String]'
    fn append(inout self, list: List[T]):
    ^
/home/asifar/.modular/pkg/packages.modular.com_mojo/bin/mojo: error: failed to parse the provided Mojo
list.mojo8.76KB
Was this page helpful?