You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handling scalar values with extract and length functions. #1576
I was about to pull length function implementation (as in #1542), but realized that it would first probably make sense to propose a minor improvement for the extract function since it's closely related.
Currently, a scalar value (e.g. any non-array/list value) handling by extract is somewhat undefined. Certain types just pass through while others rise a errors, for example:
results {
c: extract(123, 1); // OK, outputs c: extract(123, 1);
d: extract(#123, 1); // non_object_property_loadError: error evaluating function `extract`
c: extract('123', 1); // undefined_methodError: Object 1 has no method 'genCSS'
a: extract(name, 1); // undefined_methodError: Object n has no method 'genCSS'
// etc.
}
So my proposal is: both extract and length should treat a single value as an array of length 1. The rationale behind this is quite simple I think: any code working with an arbitrary number of values (as a variable(s) or a mixin argument(s)) would be able to handle both array/list and scalar input in the same uniform manner.
Here's a typical use-case example I think of:
Activity
lukeapage commentedon Oct 4, 2013
merged