Results for “return”
Small, practical examples. Search by task or narrow things down below.
Find the first occurrence of a character
C: strchr returns a pointer into the input or NULL if the character is absent.
C✓ Tested
Find the first value satisfying a condition
C++: Compare the returned iterator with end before dereferencing it.
C++✓ Tested
Find the index of an array item
PowerShell: Array.IndexOf returns -1 when the requested item is absent.
PowerShell✓ Tested
Find the insertion position for a sorted value
C++: lower_bound returns the first position whose value is not less than the search key.
C++✓ Tested
Find the position of a matching item
JavaScript: findIndex returns -1 when the predicate matches nothing.
JavaScript✓ Tested
Find the position of a matching item
TypeScript: findIndex returns -1 when the predicate matches nothing.
TypeScript✓ Tested
Find values common to two collections
C#: Intersect returns distinct values shared by the inputs.
C#✓ Tested
Handle incomplete serial input
Arduino / C: The returned byte count distinguishes a complete payload from a timed-out partial one.
Arduino / C✓ Tested
Join several strings with a separator
PowerShell: The join operator returns one string from an input collection.
PowerShell✓ Tested
List files by extension
Enumerate regular files and return their names in order.
Get-ChildItem✓ Tested
Move a file to a new name
Java: Files.move changes the path and returns the destination Path.
Java✓ Tested
Parse a GUID without an exception
C#: TryParse reports malformed values with a boolean return.
C#✓ Tested