Another technical question on how enumerate works. Can some one explain
index({10,30,40,50,60,70},enumerate(5),{})
returns
10; 20; 20; 30; 40
Expected out
10; 20; 30; 40
But same works with below std code , but not sure why?
index({10,20,30,40,50,60,70},enumerate(5)+1,{})
output :
10; 20; 30; 40; 50
Syntax
enumerate(n)
Discussion posts and replies are publicly visible
Hi,
enumerate(5) : returns : {0,1,2,3,4},
{10,30,40,50,60,70} : the Index of 10 is 1, 30 is 2 ans so on ,
INDEX : Has three parameters (array, index, default)
Note: the default value should not be array type
index({10,30,40,50,60,70},enumerate(5),null)
OR
index({10,30,40,50,60,70},{0,1,2,3,4},null)
Returns: null,10,30,40,50
Note : Array start with 1 not 0
Hey ganeshbabuj, I think you may have a typo and just wanted to clarify. You say that index({10,30,40,50,60,70},enumerate(5),{}) returns 20 but there is no 20 in the given list. Did you mean to write that index({10,20,30,40,50,60,70},enumerate(5),{}) is returning 10; 20; 20; 30; 40? This is the result that I got when I ran it. I believe it has something to do with casting {} to an integer. I replaced {} with an integer and it worked as intended. It also works with null. Thanks, Jake
The problem is not in enumerate, it is in third parameter of "index" function. Don't pass null array. problem will be solve.
If you want to write 5 in an enum, so you will get that output
If you can change it so you will get the same output as this
This is a 4.5-year-old post...
Well Mike Schmitt, nostalgia isn't what it used to be!
Oh