Created
September 12, 2014 01:19
-
-
Save peterkos/e8f0853566e2f05a4940 to your computer and use it in GitHub Desktop.
"Hello, World" by appending strings in a variety of languages. Just thought it would be fun to compare syntaxes.
This file contains hidden or 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
//Objective-C | |
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"Hello "]; //NSMutableString *str = @"Hello,"; | |
str = [str stringByAppendingString:@" world!"]; | |
NSLog(@"%@", str); //Output: Hello, world! | |
//Java | |
String newString = "Hello, "; | |
String secondString = " world!"; | |
newString += newString + oldString; | |
System.out.println(bothStrings); //Output: Hello, world! | |
//Swift | |
var str = "Hello," | |
str += " world!" | |
println(str); //Output: Hello, World! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment