The following code is legal C++ and does exactly what you’d expect it to do.
auto result = "Hello" <repeat> 3 <join> ", ";
I had no idea what that might do. No expectations at all. Is this an attempt to write language X in language Y?
auto result = "Hello" <repeat> 3 <join> ", ";
I had no idea what that might do. No expectations at all. Is this an attempt to write language X in language Y?
Really? How is it any different than: "Hello".repeat(3).join(",");
I read it as "repeat the string Hello thrice and then add a comma and space". It's not really clear that "repeat" returns a list.
A C# equivalent would be:
String.Join(", ", Enumerable.Repeat("Hello", 3))
Here it's easier to see that Repeat returns an Enumerable object.Using an Extension Method, it's easy to see how someone could mistake the output: