TypeFunction example: ImplictConvTargets

claptrap clap at trap.com
Wed Oct 7 01:07:17 UTC 2020


On Tuesday, 6 October 2020 at 23:39:24 UTC, H. S. Teoh wrote:
> On Tue, Oct 06, 2020 at 11:16:47PM +0000, claptrap via 
> Digitalmars-d wrote: [...]
>>
> I would write it like this:
>
> 	int[] vals = [4,7,28,23,585,73,12];
>
> 	int[] getMultiplesOf(int i)
> 	{
> 	    return vals.filter!(v => (v % i) == 0).array;
> 	}
>
> One line vs. 4, even more concise. ;-)

The point is to show language not library.


> Thing is, what someone finds intuitive or not, is a pretty 
> subjective matter, and depends on what programming style he's 
> familiar with and/or prefers.  What a C programmer finds 
> readable and obvious may be needlessly arcane to a Java 
> programmer, and what an APL programmer finds totally obvious 
> may be completely impenetrable to anyone else. :-P

We're not looking for "is this intuitive to Java programmers", 
we're asking is this intuitive to D programmers, so if they 
already know D then *you have context* in which to judge whether 
it's intuitive or not. And "It's just like regular D code but 
with types" pretty much hits the nail on the head as fair as 
intuitive goes.






More information about the Digitalmars-d mailing list