Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Anonymous objects and initialization lists

  • You cannot reply to this topic
2 replies to this topic

#1 cvet   Members   -  Reputation: 163

Like
0Likes
Like

Posted 06 June 2014 - 06:37 AM

As i see in documentation this must work, but i have error.

void foo(dictionary d)
{
}
void foo2()
{
	foo(dictionary = { { "1", 1 }, { "2", 2 }, { "3", 3 } });
}

Output:

INFO : Compiling void foo2().
ERROR : Expected expression value.
ERROR : Instead found '{'.
ERROR : Expected expression value.
ERROR : Instead found ')'.



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3227

Like
0Likes
Like

Posted 06 June 2014 - 08:35 AM

It's a conflict with the named arguments features that was introduced in this WIP. I'll see if I can resolve this.

 

In the meantime you can work around it by putting the anynomous object expression between parenthesis, like this:

 

void foo2()
{
   foo( (dictionary = { { "1", 1 }, { "2", 2 }, { "3", 3 } }) );
}

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3227

Like
0Likes
Like

Posted 06 June 2014 - 06:06 PM

It turns out that it was quite trivial to fix. You can get the fix in revision 1950.

 

Regards,

Andreas


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game





PARTNERS