Recent improvements

Bienlein jeti789 at web.de
Wed Feb 19 04:29:56 PST 2014


On Sunday, 16 February 2014 at 13:22:09 UTC, bearophile wrote:
> In the last days of beta3 D+Phobos is getting better in small 
> but significant ways:
>
> immutable s = ["red", "blue"];
> auto js = s.join;
>
> This is very handy because you can join arrays from constant 
> function arguments, or the result of a map that yields const 
> items, etc.
>
> -----------------------
>
> And I am finding the optional column number in error messages 
> very handy, my editor/IDE often jumps at the right column, 
> saving me tiny amounts of time that adds up making the 
> debugging nicer. The experience is just better than before.
>
> -----------------------
>
> auto r = [10, 20, 30].sum;

There is the nice old Smalltalk-80 inject:into: method in the 
Collection class:

| list sum |
list := OrderedCollection new add: 1; add: 2; add: 3; yourself.
sum := list inject: 0 into: [ :a :b | a + b ].
Transcript cr; show: sum.  "prints 6"

A little more general ;-). The Scala guys have also cloned it 
where it is called foldLeft.


More information about the Digitalmars-d mailing list