In Scala, how can I convert a comma separated string to an array to a quoted string?
E.g. in R I'd use:
> bold_statement_string <- "narcos,is,maybe,better,than,the,wire"
[1] "narcos,is,maybe,better,than,the,wire"
> bold_statement_array <- strsplit(bold_statement_string, ',')[[1]]
[1] "narcos" "is" "maybe" "better" "than" "the" "wire"
> cat(paste(shQuote(bold_statement_array), collapse = ','))
'narcos','is','maybe','better','than','the','wire'
In Scala, it worked with:
var bold_statement_string = "narcos,is,maybe,better,than,the,wire"
var bold_statement_array = bold_statement.split(',')
s"'${bold_statement_array.mkString("','")}'"
Out[83]:
'narcos','is','maybe','better','than','the','wire'
In python I hear there's always a pythonic way of doing it. Is there a more Scala-esk way of doing it? Or should I just rejoice in having found a solution, no matter if it could be more elegant?