Skip to content

Using the in statement #1314

Answered by SquidDev
stacode123 asked this question in Q&A
Jan 26, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

No - the in keyword is only used for looping over things (for k, v in pairs(some_table) do ... end).

If you want to check if one string is in another, you can use Lua patterns and string.find:

local a = "a"
local b = "ab"
if b:find(a, 1, true) then
  -- something
end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stacode123
Comment options

Answer selected by stacode123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants