Difference between revisions of "String Operations"
From mi-linux
Jump to navigationJump to search (New page: == Really, really, long strings == Instead of using '''"''' you can use '''"""''' as a string delimeter if you want to define a really, really long string that is split over several lines...) |
(No difference)
|
Revision as of 02:16, 21 February 2011
Really, really, long strings
Instead of using " you can use """ as a string delimeter if you want to define a really, really long string that is split over several lines. Like this:
val really_long_string = """<html> <head> <title>Looooong Scala String</title> </head> <body> <h1>This is a very long string indeed!</h1> </body> </html>""" println(really_long_string)
Splitting strings
scala> val mystring = "Hello, I like Scala! It, does, rock." mystring: java.lang.String = Hello, I like Scala! It, does, rock. scala> mystring.split(",") res0: Array[java.lang.String] = Array(Hello, I like Scala! It, does, rock.) scala> mystring.split(",").foreach((msg:String) => println(msg)) Hello I like Scala! It does rock. scala>