❤🔥
❤🔥
MModular
Created by ❤🔥 on 9/16/2023 in #questions
Data type conversion
how can I convert String to StringLiteral?
5 replies
MModular
Created by ❤🔥 on 9/16/2023 in #questions
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")
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
/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
14 replies