digitalmars.D.learn - aa literals
- Ellery Newcomer (3/3) Mar 13 2010 anyone know of a good (or any) syntax for an empty aa
- bearophile (12/13) Mar 13 2010 Unfortunately "null" suffices where the function that receives knows the...
- Philippe Sigaud (10/13) Mar 13 2010 To associate a list of key/value pairs into one AA?
- bearophile (4/7) Mar 13 2010 Sorry, I have probably not understood your question.
- Ellery Newcomer (5/12) Mar 13 2010 No, you hit it on the head. Here's the kind of thing I was after:
- bearophile (4/5) Mar 14 2010 I don't understand the question, sorry.
anyone know of a good (or any) syntax for an empty aa impetus: auto aa = reduce!(g)(emptyaa, lst);
Mar 13 2010
Ellery Newcomer:anyone know of a good (or any) syntax for an empty aaUnfortunately "null" suffices where the function that receives knows the type of the AA it will receive. But I don't like this, a more typed style can be less bug prone. So you can give a type to null: cast(int[string])null I have created a bit shorter template: AA!(string, int) But it doesn't gain much. Something similar can be used for dynamic arrays: cast(int[])null With dynamic arrays you can also use (that I don't like) "null" and even the special [] Bye, bearophile
Mar 13 2010
On Sat, Mar 13, 2010 at 20:17, Ellery Newcomer <ellery-newcomer utulsa.edu>wrote:anyone know of a good (or any) syntax for an empty aa impetus: auto aa = reduce!(g)(emptyaa, lst);To associate a list of key/value pairs into one AA? I use .init, but AA in general have become buggy for the past few releases. auto aa = reduce!g((V[K]).init, lst); // this used to work, I think But, as I said, it has become quite buggy recently: auto aa = (int[string]).init; // empty AA? aa["abc"] = 3; // error, no operator [] overload for AssociativeArray!(string, int). I mean, come on. Philippe
Mar 13 2010
Ellery Newcomer:anyone know of a good (or any) syntax for an empty aa impetus: auto aa = reduce!(g)(emptyaa, lst);Sorry, I have probably not understood your question. Bye, bearophile
Mar 13 2010
On 03/13/2010 07:20 PM, bearophile wrote:Ellery Newcomer:No, you hit it on the head. Here's the kind of thing I was after: auto g = reduce!("a[b]=1,a")(cast(int[int]) null, [1,2,3,4]); Works fine. The one-liner probably isn't worth it, but I think it's pretty funny. What does this do to Walter's arguments concerning nonnull?anyone know of a good (or any) syntax for an empty aa impetus: auto aa = reduce!(g)(emptyaa, lst);Sorry, I have probably not understood your question. Bye, bearophile
Mar 13 2010
Ellery Newcomer:What does this do to Walter's arguments concerning nonnull?<I don't understand the question, sorry. Bye, bearophile
Mar 14 2010