Created
September 26, 2015 20:52
-
-
Save ceylonwebide/2aaab60d0ddd6b83baec to your computer and use it in GitHub Desktop.
Ceylon Web Runner: strings.ceylon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$webrun_wrapped | |
shared void run() { | |
//Strings come in two forms, ordinary, single-quoted strings, | |
//where backslashes represent escapes: | |
print("Hello\nworld"); | |
//And "verbatim" strings, where quotes and backslashes are | |
//interpreted literally: | |
print("""Hello\nworld"""); | |
//String literals can span multiple lines: | |
print("Hello | |
world"); | |
print("""Hello | |
world"""); | |
//We can use the + operator to concatenate strings: | |
value strings = {"world", "everyone"}; | |
for (who in strings) { | |
print("Hello " + who); | |
} | |
//String interpolation allows us to write expressions within | |
//a string literal: | |
for (who in strings) { | |
print("Hello ``who``"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Click here to run this code online