Re: How to add a character literal to a string without ~ operator?

2024-04-08 Thread IchorDev via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. Concatenate is the verb you're looking for, not add. 'Adding' a `char` to a `string` sounds like you want `myString[] += myChar;`, which

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 4 April 2024 at 21:23:00 UTC, user1234 wrote: On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: [...] ```d module runnable; import std.stdio : writeln; import std.range : chain; void main() @nogc { auto s = chain("as ", "df ", "j"); // s is lazy

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: My favorite d feature is lazy ranges. No allocation here. ```d auto s = chain("as ", "df ", "j"); // s is lazy writeln(s); ``` ```d import std.range : chain; void main() { string word = "hello"; auto noError = chain(word,

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread user1234 via Digitalmars-d-learn
On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard

How to add a character literal to a string without ~ operator?

2024-04-04 Thread BoQsc via Digitalmars-d-learn
I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard library. The function should be straightforward, up to