Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Block Conditional Statement returns wrong value #1399

Closed
paoloemilioserra opened this issue Nov 22, 2016 · 3 comments
Closed

Code Block Conditional Statement returns wrong value #1399

paoloemilioserra opened this issue Nov 22, 2016 · 3 comments

Comments

@paoloemilioserra
Copy link

If this issue is not a bug report or improvement request, please check the Dynamo forum, and start a thread there to discuss your issue.

Dynamo version

1.2.0.2690

Revit version

2017.1

Operating system

Windows 7

What did you do?

I'm using a conditional statement in a code block, when the input "a" is greater than 3 it should return a list of the inner elements, otherwise a list containing only the second item. Here is the formula.
output = Count(a) > 3 ? a[1..Count(a) - 2] : {a[1]};

What did you expect to see?

let's a = {0, 1, 2, 3} -> output = {1, 2}
let's a = {0, 1, 2} -> output = {1}

What did you see instead?

The above formula always return the false member. If I remove the curly brackets from the false member if works properly but I need a list of 1 item and not just the item

@paoloemilioserra paoloemilioserra changed the title Code Block Conditional Statement return wrong value Code Block Conditional Statement returns wrong value Nov 22, 2016
@andydandy74
Copy link

It's a feature. :-D Really.
Try this:

result[0] = a[1..Count(a) - 2];
result[1] = {a[1]};
result[Count(a) > 3 ? 0 : 1];

This has been discusssed here:
DynamoDS/Dynamo#6491
And here:
DynamoDS/Dynamo#6258
And here:
DynamoDS/Dynamo#4464
And here:
DynamoDS/Dynamo#3106

@paoloemilioserra
Copy link
Author

paoloemilioserra commented Nov 22, 2016

Thanks! I still think that it should return a list as a variable type though

@andydandy74
Copy link

You're not alone with that sentiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants