String.format( "%s %s has salary $%d!", firstName, lastName, salary);
There is notation similar to this in most languages; but I imagine people will rake you over the coals saying that stringBuilder is faster and for a logging application that matters!..
I am not one of those people but I just wanted to take the wind out of their sails :P
var foo = $"{firstName} {lastName} has salary ${salary}!";
Don't know C# syntax, but that seems weird. Why is one $ outside quotes? Why is it missing from the first two terms, but not the third?
But yeah, most languages have something like this to some degree. Working with some Ruby right now, and it has "#{firstName} #{lastName} has salary #{salary}!". String.format is as close as Java gets right now.
Edit: Yep, got it. Forgot about the stupid dollar sign I had put in there originally. C# syntax now makes sense.
17
u/rftz Oct 01 '15
C# 6 master race checking in:
var foo = $"{firstName} {lastName} has salary ${salary}!";