The clamped gem allows to filter values by a provided whitelist. For example, "apple".clamped(%w[apple banana]) # "apple". If apple is not part of the array, nil is returned. This is e.g. useful to filter values provided by user input.
"apple".clamped(%w[apple banana]) # "apple"
apple
nil
See All 1177 Episodes of "RubyFlow"