How can I convert String to StringLiteral
I understood that
str()
is required to convert things to String like (StringLiteral, Int, Bool, ...), but is there a way to covert String to LiteralString.
As part of learning Mojolang I'm trying the below code, then this conversion issue poped up.
3 Replies
StringLiteral
is a type which literally means "string typed directly into the file". There is no way to turn a string into a string literal. It's used in places like ORMs to make anything that could produce SQL injection a type error.I’m brand new to Mojo myself, would it work to make the 3rd type of the alias be String not StringLiteral?
This way you can convert StringLiteral to String where/if needed. I’m running into these kind of issues learning the language myself, so I appreciate that you’re sharing @Hasan Yousef
Yes, you would want to use
String
, not StringLiteral
for the third type in the alias.