Evaluation of array.filter with function pointer not working
See original GitHub issueUsing the exampe template from the documentation of array.filter:
var result = Template.Parse("{{['', '200', '','400'] | array.filter @string.empty}}").Replace(new TemplateContext());
The above gives the desired result:
["", ""]
Using Evaluate instead of Replace:
var result = Template.Parse("{{['', '200', '','400'] | array.filter @string.empty}}").Evaluate(new TemplateContext());
returns an object of type ScribanRange. When trying to iterate the items in result, i get the following exception:
Value cannot be null. (Parameter 'callerContext')
at Scriban.Syntax.ScriptFunctionCall.Call(TemplateContext context, ScriptNode callerContext, IScriptCustomFunction function, ScriptArray arguments)
at Scriban.Functions.ArrayFunctions.FilterInternal(TemplateContext context, SourceSpan span, IEnumerable list, IScriptCustomFunction function, Type destType)+MoveNext()
at Scriban.Runtime.ScriptRange.GetEnumerator()+MoveNext()
Expectation would be to either be able to iterate over the result or directly getting an array or list as a result. Am I doing anything wrong here?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
How is filter function working for different types of pointers?
A unique problem with your filter function is that creating a new array that potentially shares data with the previous array opens up...
Read more >Function Pointers in C are Underrated : r/programming
I like function pointers as a mechanism for callbacks, but I'm not that sure if the author's example of a function pointer being...
Read more >Arrays - Rhai - Embedded Scripting for Rust
Function Parameter(s) Description
push , += operator array; element to append (not another array) appends an element to the...
+ operator first array; second array...
Read more >Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >array_filter - Manual
Iterates over each value in the array passing them to the callback function. If the callback function returns true , the current value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed by commit d77a23736ecc3a90fe204799ee53e73a929e5870
nice - thanks!