B01C
find
should return null
when the pattern wasn't found
#1383
Labels
8000
find
should return null
when the pattern wasn't found
#1383
A note for the community
Problem
Discussed in #1311
Right now it returns
-1
, which from what I can see is somewhat of a special case, because in other functions if something could not be found,null
is returned. Returning-1
might introduce hidden bugs if the return value is not analyzed, for example:This code will compile without issues, and the value stored in
output
will be"r"
. Maybe it would be better to returnnull
(which will fail theslice!()
function) or make thefind!()
function fail if the pattern wasn't found, requiring the developer to handle that case explicitly.VRL Program
VRL and/or Vector Version
VRL Version: 0.22.0
Debug Output
Example
Playground Link
Additional Context
No response
References
Discussed in #1311
The text was updated successfully, but these errors were encountered: