Input:
void main()
{
import std.stdio : writeln;
writeln("Hello, World!\n");
//I'm not sure if the ^^ is necessary or not
}
Output:
Hello, World!
That's it.
Thread overview | |||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 25, 2022 Hello, World! | ||||
---|---|---|---|---|
| ||||
Input:
Output:
That's it. |
March 25, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anonymous | Welcome! :) (We have a Learn forum (newsgroup) as well, where such posts are more suitable.) On 3/25/22 13:07, Anonymous wrote: > **Input:** > ```d > void main() > { > import std.stdio : writeln; > writeln("Hello, World!\n"); > //I'm not sure if the ^^ is necessary or not It may be useful if you want an additional empty line. ;) Otherwise, writeln is short form "write line", implying a newline will be printed at the end. (Conversely, write() does not add a newline.) > } > ``` > > **Output:** > ``` > Hello, World! > ``` > That's it. I like it! :) Ali |
March 25, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anonymous | On Hello, World! at some time, Anonymous wrote: >Input:
Output:
That's it. Maybe this could be an added example for the example box found in the dlang homepage |
March 26, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 25 March 2022 at 20:29:22 UTC, Ali Çehreli wrote: >It may be useful if you want an additional empty line. ;) Otherwise, writeln is short form "write line", implying a newline will be printed at the end. (Conversely, write() does not add a newline.) If a website was used to compile/output data, it might have truncated the newline(s). HTML afterall doesn't honor whitespacing. If it were preformatted aka then would honor the text formatting. Using octal dump you could see the actual output.
|
March 26, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anonymous | On Friday, 25 March 2022 at 20:07:39 UTC, Anonymous wrote: >
Thank you... I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy". Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:
Because it's functional... SDB@79 |
March 28, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Salih Dincer | On Saturday, 26 March 2022 at 04:03:08 UTC, Salih Dincer wrote: >Thank you... I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy". Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:
Because it's functional... SDB@79 Throwing my hat in the ring:
|
March 28, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to FeepingCreature | On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote: >Throwing my hat in the ring:
Report failure in case of success? :) ( |
March 28, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | On 3/28/22 06:33, Stanislav Blinov wrote: > On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote: > >> Throwing my hat in the ring: >> >> ```d >> import std.stdio; >> int main() >> => "Hello World".puts; >> ``` > > Report failure in case of success? :) We have precedent in rt_init: :) https://dlang.org/phobos/core_runtime.html#.rt_init It is not obvious from its documented "returns 1/0" but it is a translation of Runtime.initialize's true/false: https://dlang.org/phobos/core_runtime.html#.Runtime.initialize Ali |
March 28, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | On Mon, Mar 28, 2022 at 01:33:55PM +0000, Stanislav Blinov via Digitalmars-d wrote: > On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote: > > > Throwing my hat in the ring: > > > > ```d > > import std.stdio; > > int main() > > => "Hello World".puts; > > ``` > > Report failure in case of success? :) (`puts` returns a "non-negative > value" on success, which, with that wording, is not necessarily 0). > Cute though. This should fix the return code: import std.stdio; int main() => !(1 + "Hello World".puts); :-P (Well OK, this is a hack, EOF is not necessarily -1. But it is on my system.) T -- The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5 |
March 28, 2022 Re: Hello, World! | ||||
---|---|---|---|---|
| ||||
Posted in reply to FeepingCreature | On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote: >On Saturday, 26 March 2022 at 04:03:08 UTC, Salih Dincer wrote: >Thank you... I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy". Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:
Because it's functional... SDB@79 Throwing my hat in the ring:
I'll try another2 line version
|