Module:Util/strings/ startsWith: Difference between revisions

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
(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

#InputOutputResult
1
local startsWithA = util.strings._startsWith("A")
return {
  startsWithA("Agahnim"),
  startsWithA("Ganon"),
}
Expected
{true, false}
Actual
{false, false}
2
local names = {"Agahnim", "Ganon", "Arrghus"}
local startsWithA = util.strings._startsWith("A") 
local namesStartingWithA = util.tables.filter(names, startsWithA)
return namesStartingWithA
Expected
{"Agahnim", "Arrghus"}
Actual
{}

local startsWith = require("Module:Util/strings/startsWith")

local function _startsWith(substr)
	return function(str)
		return startsWith(substr, str)
	end
end

return _startsWith