vex - vector set()

   2725   3   2
User Avatar
Member
48 posts
Joined: Feb. 2013
Offline
Hi , what is the difference between these 2 vector assignments :
vector myVect = set(1,2,3);
vector myVect = {1,2,3};

Thanks
User Avatar
Member
483 posts
Joined: Dec. 2006
Offline
In this case nothing
but:

float foo = 0.5;

vector myVect = set(1,foo ,3); // will work
vector myVect = {1,foo ,3}; // errors out
English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
48 posts
Joined: Feb. 2013
Offline
matthias_k
In this case nothing
but:

float foo = 0.5;

vector myVect = set(1,foo ,3); // will work
vector myVect = {1,foo ,3}; // errors out

Yes, that's what confused me. The “{}” can't take variable … is it design like that or is it a bug ?
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
It's neither by design or a bug.

Perhaps you could say it is ‘by design’ indirectly;

The curly braces are not a “function” - they are simply part of a syntax structure that we can use in certain contexts, in this case along with the combination of = , and ; characters that allow us to assign values to ‘myVec’.

There's nothing to tell the compiler what foo is or how it should be handled, to do that, we need a simple function;

like say - the set() function, that can handle what foo is.

All you more knowledgeable people out there - please do chime and correct me or rephrase/add to what I've said if wrong.
Edited by BabaJ - April 21, 2018 19:42:54
  • Quick Links