Confusion about `Random`

Salih Dincer salihdb at hotmail.com
Sat Dec 24 19:05:40 UTC 2022


On Saturday, 24 December 2022 at 17:58:04 UTC, jwatson-CO-edu 
wrote:
> Ali, your post contained at least 3 things I did not previously 
> know about D; thank you!
>
> And thank you all for helping troubleshoot this issue with my 
> hobby language!

Thank you for completing me: Tesekkurler hocam in Turkish.

Meanwhile, the compile-time and associative array capabilities 
are incredible:

```d
alias oT = int;
enum opMap =
[ "×": (oT a, oT b) => a * b,
   "÷": (oT a, oT b) => a / b,
   //...
];

auto doubleAndDivide(oT first, oT second) {
   const foldedDouble = opMap["×"](first, 2);
   return opMap["÷"](foldedDouble, second);
}

void main()
{
   assert(6.doubleAndDivide(3) == 4);
}
```

Don't you think it's delicious too? It's impossible not to love D.

SDB at 79


More information about the Digitalmars-d-learn mailing list