Module:Util/strings/ startsWith: Difference between revisions
< Module:Util | strings
PhantomCaleb (talk | contribs) (Created page with "local startsWith = require("Module:Util/strings/startsWith") local function _startsWith(substr) return function(str) return startsWith(substr, str) end end return _startsWith") |
(No difference)
|
Revision as of 19:54, 19 May 2024
A curried version of Module:Util/strings/startsWith.
_startsWith(substr)
Returns
- A function that accepts a string and returns a boolean indicating whether the string starts with
substr
.
Examples
# | Input | Output | Result | ||||
---|---|---|---|---|---|---|---|
1 | local startsWithA = util.strings._startsWith("A")
return {
startsWithA("Agahnim"),
startsWithA("Ganon"),
}
|
| |||||
2 | local names = {"Agahnim", "Ganon", "Arrghus"}
local startsWithA = util.strings._startsWith("A")
local namesStartingWithA = util.tables.filter(names, startsWithA)
return namesStartingWithA
|
|