It would be beneficial to have a method that returns only one of each item in the collection that matches a particular value.
collect({1, 1, 2, 2, 3, 4, 2}):methodName():all()
-- {1, 2, 3, 4}
collect({
{ animal = 'Cat', name = 'Bob' },
{ animal = 'Dog', name = 'Tim' },
{ animal = 'Cat', name = 'Beverly' }
}):methodName('animal'):all()
--[[
{
{ animal = 'Cat', name = 'Bob' },
{ animal = 'Dog', name = 'Tim' }
}
]]
collect({
{ animal = 'Cat', name = 'Bob' },
{ animal = 'Dog', name = 'Tim' },
{ animal = 'Cat', name = 'Beverly' }
}):methodName(function(key, value)
return value:sub(1,1)
end):all()
--[[
{
{ animal = 'Cat', name = 'Bob' },
{ animal = 'Dog', name = 'Tim' }
}
]]
It would be beneficial to have a method that returns only one of each item in the collection that matches a particular value.