Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Created August 18, 2010 11:12
Show Gist options
  • Save benlangfeld/534360 to your computer and use it in GitHub Desktop.
Save benlangfeld/534360 to your computer and use it in GitHub Desktop.
An example of why Ruby is simply the best
var conversationAsString = "";
for(var i=0; i < [aMessages count]; i++) {
m = aMessages[i];
var messageTime = [CPDate dateWithTimeIntervalSinceNow:0];
var messageBody = [[m firstChildWithName:@"body"] text];
var messageAsString = "[" + messageTime + "] " + [m from] + ": " + messageBody;
conversationAsString += messageAsString + "\n";
}
CPLog.info(conversationAsString);
puts messages.map { |m| "[#{Time.now}] #{m.from}: #{m.body.value}" }.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment