On Saturday, 12 September 2015 at 18:23:55 UTC, Adam D. Ruppe wrote:
On Saturday, 12 September 2015 at 16:34:42 UTC, Meta wrote:
Maybe because the static type system allows for overloading and so all of these utility functions don't have to do a million different things depending on what you pass to them.

Yea. Another huge thing to me is the slice operator. I use it for a lot of stuff and it is consistent for strings and other arrays. (well, utf issues aside, but D's rule there is simple enough to remember too)

Arrayviews ("slices") are available as a type so you can do it like this:

a = new Uint32Array([7,2,3,6]) // a is [7, 2, 3, 6]
b = a.subarray(1,3) // b reference [2, 3]
b[0] = 8 // now a is [7, 8, 3, 6]
a.set([5,9], 2) // now a is [7,8,5,9]

Destructuring is coming too. So you can destructure arrays as if they are tuples. E.g.:

var a,b;
[a,b] = [2,4]
[a,b] = [b,a]

I think it might work in TypeScript or some of the other compilers already.

Reply via email to