0

I don't know convert String to array in Play scala. String contains "test1,test2,test3,test4". I want to split a string into array like

a[0]=test1,a[1]=test2,a[3]=test3,a[4]=test4
4
  • So you're looking for a function: String => Array[String]? Example: f("test1,test2,test3,test4") == Array("test1", "test2", "test3", "test4")? Commented May 24, 2016 at 13:58
  • yes, have any solution to convert? and how to do in scala.html Commented May 24, 2016 at 14:02
  • I tried this one but getting some errors Array[java.lang.String] items = (@Testing.values).split(",") Commented May 24, 2016 at 14:10
  • Although I directly answered your question, what are you trying to do exactly? Commented May 24, 2016 at 18:36

1 Answer 1

2
scala> "test1,test2,test3,test4".split(",")
res1: Array[String] = Array(test1, test2, test3, test4)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.