List and strings

hey, how can one add a string value into a list.
for example “206” adding it to [1, 2, 4, 5, 6].

Thanks :slight_smile:

At the end or at the beginning?

at the end

and how do i convert the same string in to a list?

“206” as a string into [206] as a list

You can use and do

[1, 2, 4, 5, 6] ++ ["206"]

Take a note that adding at the end is often an expensive operation in Elixir since the lists are represented as linked lists under the hood

If you want to add at a concrete positions use
At the beginning use ["206" | [1, 2, 4, 5, 6]]


You can do "206" |> String.to_integer() |> List.wrap()


how to cast a list in one column in the Db