Elegant D
cc
vugewb+3ogyxzlhhabew at grr.la
Wed Dec 3 16:52:43 UTC 2025
On Tuesday, 25 November 2025 at 01:18:21 UTC, Walter Bright wrote:
> I'm interested in anecdotes, experiences and examples of
> Elegant D to incorporate!
2D slicing in my 2D array/Grid struct (which just holds a 1D
array under the hood):
```d
auto grid = Grid!char(6, 4, '.');
grid[2..4, 1..3] = '#';
writeln(grid);
```
```
[......]
[..##..]
[..##..]
[......]
```
I enjoy the gameplay loop of "Write complex structure code with
ultra-simple usage that abstracts away all that complexity when
you need to actually do something with it, so your main() looks
clean as a whistle".
Also, easy UFCS templates:
```d
SomeObject someObj = ...
SomeStruct someStruct = ...
// Writes all aggregate member-value pairs without the need of
builtin toString methods
writeln(someObj.toStringer);
writeln(someStruct.toStringer(recursive:true));
```
More information about the Digitalmars-d
mailing list