4 ms·
Looked at their site the other day and saw they got string interpolation backwards from the shell (“” vs ‘’), how is that possible?
by mixmastamyk 9y ago
Looked at their site the other day and saw they got string interpolation backwards from the shell (“” vs ‘’), how is that possible?
- johnhattan 9y agoIIRC, you can use either. Whatever quote you used to start the string is the one that will end the string. var foo:String = "foo"; // foo var bar:String = 'bar'; // bar var fooquotebar:String = "foo'bar"; // foo'bar
- subwayclub 9y agoThat doesn't cover the interpolation part of it, though. var z = "This is just a literal value"; var q = 'This automatically runs Std.format, letting me include "$z"';
- deleted 9y ago[deleted]
- RussianCow 9y agoShell and basically every other language that makes that distinction (PHP, Ruby, Perl...).
- bendmorris 9y agoThis is pretty annoying, but you get used to it. After so long it would be a major pain to break everyone's strings by flipping the syntax.
- to3m 9y agoThey probably started with quoted string literals (same syntax as ActionScript, I think, plus many other languages of course), then added string interpolation later and realised they needed a different syntax for it. (Another option: they looked at what the POSIX-style shell does, and did exactly the opposite. And as language design strategies go, that is far from the worst possible.)
- mixmastamyk 9y agoYou’re probably correct, though I think string interpolation is one of the things posix got mostly right.