Tip: Find and type narrow an element from an array in ruby and sorbet
Published
Last updated
Recently I had a problem where I had to find the first matching element of an
array by type. Ruby provides a method to return the first matching (or nil
)
element in an array, but sorbet isn't smart enough to type narrow it when the
match is related to the type of the element…