factoriolib / flib

A set of high-quality, commonly-used utilities for creating Factorio mods.
https://mods.factorio.com/mod/flib
MIT License
61 stars 15 forks source link

Documentation for table.find() mismatch #36

Closed Majoca22 closed 2 years ago

Majoca22 commented 2 years ago

The current usage documentation for table.find() is:

local tbl = {"foo", "bar"}
local contains_foo = table.search(tbl, "foo") -- true
local contains_baz = table.search(tbl, "baz") -- false

which isn't demonstrating the table.find() function, and is instead using table.search() (which I don't see in the table module?)

raiguard commented 2 years ago

Sorry about that! Don't have doctests so sometimes these things slip through the cracks.

Majoca22 commented 2 years ago

Thanks for addressing this! I'm still not sure the documentation is correct though; wouldn't table.find(tbl, "foo") return 1 (the key of foo) and table.find(tbl, "baz") return nil?

raiguard commented 2 years ago

Holy crud, I really dropped the ball on the docs for this function. Thanks!