search array

How would you go about creating a search edittext dialog to search an array?

eg.

myarray = #("name1, "name2", "name3")

search with keyword like 1 to return string name of name1.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

myarray = #("name1", "name2",

myarray = #("name1", "name2", "name3")
fn searchByIndex arr:#() idx:1 =
(
	local found 
	if arr.count!=0 do found = arr[idx]
	found 
)
 
searchByIndex arr:myarray idx:2
--if not found then return undefined

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.